Skip to content

Commit 789eaad

Browse files
committed
PDFBOX-5025: Unread trailing e in numbers, by Cody Wayne Holmes; closes #91
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922732 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1abe8ca commit 789eaad

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,15 @@ private COSNumber parseCOSNumber() throws IOException
999999
{
10001000
source.rewind(1);
10011001
}
1002+
1003+
// PDFBOX-5025: catch "74191endobj"
1004+
char lastc = buf.charAt(buf.length() - 1);
1005+
if (lastc == 'e' || lastc == 'E')
1006+
{
1007+
buf.deleteCharAt(buf.length() - 1);
1008+
source.rewind(1);
1009+
}
1010+
10021011
return COSNumber.get(buf.toString());
10031012
}
10041013

pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestPDFParser.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
import java.net.URISyntaxException;
2626

2727
import org.apache.pdfbox.Loader;
28+
import org.apache.pdfbox.cos.COSName;
2829
import org.apache.pdfbox.pdmodel.PDDocument;
2930
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
31+
import org.apache.pdfbox.pdmodel.font.PDFont;
3032
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline;
3133
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
3234
import org.apache.pdfbox.rendering.PDFRenderer;
@@ -348,4 +350,20 @@ void testPDFBox4490() throws IOException
348350
}
349351
}
350352

353+
/**
354+
* PDFBOX-5025: Test for "74191endobj"
355+
*
356+
* @throws IOException
357+
*/
358+
@Test
359+
void testPDFBox5025() throws IOException
360+
{
361+
try (PDDocument doc = Loader.loadPDF(new File(TARGETPDFDIR, "PDFBOX-5025.pdf")))
362+
{
363+
assertEquals(1, doc.getNumberOfPages());
364+
PDFont font = doc.getPage(0).getResources().getFont(COSName.getPDFName("F1"));
365+
int length1 = font.getFontDescriptor().getFontFile2().getCOSObject().getInt(COSName.LENGTH1);
366+
assertEquals(74191, length1);
367+
}
368+
}
351369
}

0 commit comments

Comments
 (0)