pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1716241 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java
Date Tue, 24 Nov 2015 20:17:28 GMT
Author: tilman
Date: Tue Nov 24 20:17:28 2015
New Revision: 1716241

URL: http://svn.apache.org/viewvc?rev=1716241&view=rev
Log:
PDFBOX-2158, PDFBOX-3130: fix out-of-bounds value in font BBox for text extraction

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java?rev=1716241&r1=1716240&r2=1716241&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java Tue
Nov 24 20:17:28 2015
@@ -29,6 +29,7 @@ import org.apache.pdfbox.pdmodel.font.PD
 import org.apache.pdfbox.pdmodel.graphics.state.PDGraphicsState;
 
 import java.io.IOException;
+import org.apache.fontbox.util.BoundingBox;
 import org.apache.pdfbox.util.Matrix;
 import org.apache.pdfbox.util.Vector;
 import org.apache.pdfbox.contentstream.operator.DrawObject;
@@ -145,8 +146,15 @@ class PDFTextStreamEngine extends PDFStr
         float horizontalScaling = state.getTextState().getHorizontalScaling() / 100f;
         Matrix textMatrix = getTextMatrix();
 
+        BoundingBox bbox = font.getBoundingBox();
+        if (bbox.getLowerLeftY() <= Short.MAX_VALUE)
+        {
+            // PDFBOX-2158 and PDFBOX-3130
+            // files by Salmat eSolutions / ClibPDF Library
+            bbox.setLowerLeftY(bbox.getLowerLeftY() + 65536);
+        }
         // 1/2 the bbox is used as the height todo: why?
-        float glyphHeight = font.getBoundingBox().getHeight() / 2;
+        float glyphHeight = bbox.getHeight() / 2;
 
         // transformPoint from glyph space -> text space
         float height = font.getFontMatrix().transformPoint(0, glyphHeight).y;



Mime
View raw message