@@ -832,15 +832,13 @@ private List<Double> parseTextShowArgument(COSBase argument, StringBuilder unico
832832 double shift = - obj .getReal () / 1000 *
833833 graphicsState .getTextState ().getTextFontSize () *
834834 graphicsState .getTextState ().getHorizontalScaling ();
835- if (-obj .getReal () >= TextChunkUtils .TEXT_CHUNK_SPACE_RATIO && StaticStorages .getIsAddSpacesBetweenTextPieces ()) {
836- textPieces .add (new TextPieces .TextPiece (" " , textPieces .getCurrentX (),
837- textPieces .getCurrentX () + shift ));
838- } else {
839- textPieces .shiftCurrentX (shift );
840- }
835+ textPieces .shiftCurrentX (shift );
841836 }
842837 }
843838 }
839+ double threshold = graphicsState .getTextState ().getTextFontSize () * TextChunkUtils .TEXT_LINE_SPACE_RATIO ;
840+ textPieces .addSpaces (threshold );
841+
844842 unicodeValue .append (textPieces .getValue ());
845843 if (!textPieces .isEmpty ()) {
846844 textMatrix .concatenate (Matrix .getTranslateInstance (textPieces .getStartX (), 0 ));
@@ -867,17 +865,18 @@ private void parseString(COSString string, StringBuilder unicodeValue, TextPiece
867865 " in font" + graphicsState .getTextState ().getTextFont ().getName ());
868866 width = 0.0 ;
869867 }
870- double shift = (width *
871- graphicsState .getTextState ().getTextFontSize () / 1000 +
872- graphicsState .getTextState ().getCharacterSpacing () + (code == 32 ?
868+ double shift = (graphicsState .getTextState ().getCharacterSpacing () + (code == 32 ?
873869 graphicsState .getTextState ().getWordSpacing () : 0 )) *
874870 graphicsState .getTextState ().getHorizontalScaling ();
875- String value = graphicsState .getTextState ().getTextFont ().toUnicode (code );
871+ width = width *
872+ graphicsState .getTextState ().getTextFontSize () / 1000 *
873+ graphicsState .getTextState ().getHorizontalScaling ();
874+ String value = graphicsState .getTextState ().getTextFont ().toUnicode (code );
876875 if (symbolEnds != null ) {
877876 if (symbolEnds .isEmpty ()) {
878- TextChunksHelper .updateSymbolEnds (symbolEnds , shift , 0 , value != null ? value .length () : 0 );
877+ TextChunksHelper .updateSymbolEnds (symbolEnds , shift + width , 0 , value != null ? value .length () : 0 );
879878 } else {
880- TextChunksHelper .updateSymbolEnds (symbolEnds , shift , symbolEnds .get (symbolEnds .size () - 1 ),
879+ TextChunksHelper .updateSymbolEnds (symbolEnds , shift + width , symbolEnds .get (symbolEnds .size () - 1 ),
881880 value != null ? value .length () : 0 );
882881 }
883882 }
@@ -892,7 +891,8 @@ private void parseString(COSString string, StringBuilder unicodeValue, TextPiece
892891 unicodeValue .append (result );
893892 } else {
894893 textPieces .add (new TextPieces .TextPiece (result , textPieces .getCurrentX (),
895- textPieces .getCurrentX () + shift ));
894+ textPieces .getCurrentX () + width ));
895+ textPieces .shiftCurrentX (shift );
896896 }
897897 }
898898 } catch (IOException e ) {
0 commit comments