<configuration name="extract layout" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.fluidbook.fwstk.Main" />
<module name="fwstk" />
- <option name="PROGRAM_PARAMETERS" value="--input C:\Users\vince\Desktop\20929.pdf --mode robust --layout C:\Users\vince\Desktop\20929\p%d.fby --threads 1" />
+ <option name="PROGRAM_PARAMETERS" value="--input C:\Users\vince\Desktop\test.pdf --mode robust --layout C:\Users\vince\Desktop\test\p%d.fby --threads 1" />
<method v="2">
<option name="Make" enabled="true" />
</method>
<workItem from="1694674242867" duration="1038000" />
<workItem from="1694683468326" duration="1387000" />
<workItem from="1694699117438" duration="618000" />
+ <workItem from="1697471786856" duration="382000" />
+ <workItem from="1697543960076" duration="2149000" />
</task>
<task id="LOCAL-00001" summary="wip #1111 @0.5">
<created>1487172253077</created>
this.resetEngine();
this.currentPage = page;
- layout = new Page(currentPage, i,this.splitAllChars, this.ignoredSeparators);
+ layout = new Page(currentPage, i, this.splitAllChars, this.ignoredSeparators);
PDResources resources = currentPage.findResources();
PDStream contents = null;
return;
}
try {
- layout.addText(gs, getTextLineMatrix(), getTextMatrix(), text, c);
+ layout.addText(gs, getTextLineMatrix(), getTextMatrix(), text, c, true);
} catch (IOException ex) {
ex.printStackTrace();
}
this.lines = new LinkedList<>();
}
- public void addText(PDGraphicsState gs, Matrix textLineMatrix, Matrix textMatrix, TextPosition textPosition, String text) throws IOException {
+ public void addText(PDGraphicsState gs, Matrix textLineMatrix, Matrix textMatrix, TextPosition textPosition, String text, boolean splitLigatures) throws IOException {
PDTextState ts = gs.getTextState();
float rotation = new CubeMatrix(textLineMatrix).getRotation();
float size = textPosition.getFontSize() * textMatrix.getXScale();
lineScaleY /= minScale;
Line line = getLine(y, rotation, lineScaleX, lineScaleY);
- line.addText(size, x, y, width, height, text, spaceWidth);
+ if ( splitLigatures && text.length() > 1) {
+ if (isRtl(text)) {
+ for (int i = 0; i < text.length(); i++) {
+ line.addText(size, x, y, width, height, text.substring(i, i+1), spaceWidth);
+ }
+ } else {
+ for (int i = 0; i < text.length(); i++) {
+ line.addText(size, x, y, width, height, text.substring(i, i + 1), spaceWidth);
+ }
+ }
+ } else {
+ line.addText(size, x, y, width, height, text, spaceWidth);
+ }
+ }
+
+ public static boolean isRtl(String string) {
+ if (string == null) {
+ return false;
+ }
+
+ for (int i = 0, n = string.length(); i < n; ++i) {
+ byte d = Character.getDirectionality(string.charAt(i));
+
+ switch (d) {
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+ case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+ return true;
+
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+ case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+ return false;
+ }
+ }
+
+ return false;
}
public String asJSON() {
protected Line getLine(float y, float rotation, float scaleX, float scaleY) {
if (lines.size() == 0 || !lines.getLast().equals(y, rotation, scaleX, scaleY)) {
- Line newLine = new Line(y, rotation, scaleX, scaleY,splitAllChars, ignoredSeparators);
+ Line newLine = new Line(y, rotation, scaleX, scaleY, splitAllChars, ignoredSeparators);
lines.add(newLine);
return newLine;
}