pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1839690 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
Date Thu, 30 Aug 2018 16:53:27 GMT
Author: tilman
Date: Thu Aug 30 16:53:27 2018
New Revision: 1839690

URL: http://svn.apache.org/viewvc?rev=1839690&view=rev
Log:
PDFBOX-4302: add test for corner case inspired by code from Atsushi Doita

Modified:
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java?rev=1839690&r1=1839689&r2=1839690&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
Thu Aug 30 16:53:27 2018
@@ -170,6 +170,41 @@ public class TestFontEmbedding extends T
         assertEquals(expectedExtractedtext, extracted.replaceAll("\r", "").trim());
     }
 
+    /**
+     * Test corner case of PDFBOX-4302.
+     *
+     * @throws java.io.IOException
+     */
+    public void testMaxEntries() throws IOException
+    {
+        File file;
+        String text;
+        text = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"
+
+                "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン"
+
+                "12345678";
+        assertEquals(ToUnicodeWriter.MAX_ENTRIES_PER_OPERATOR, text.length());
+        PDDocument document = new PDDocument();
+
+        PDPage page = new PDPage(PDRectangle.A0);
+        document.addPage(page);
+        File ipafont = new File("target/fonts/ipag00303", "ipag.ttf");
+        PDType0Font font = PDType0Font.load(document, ipafont);
+        PDPageContentStream contentStream = new PDPageContentStream(document, page);
+        contentStream.beginText();
+        contentStream.setFont(font, 20);
+        contentStream.newLineAtOffset(50, 3000);
+        contentStream.showText(text);
+        contentStream.endText();
+        contentStream.close();
+        file = new File(OUT_DIR, "PDFBOX-4302-test.pdf");
+        document.save(file);
+        document.close();
+
+        // check that the extracted text matches what we wrote
+        String extracted = getUnicodeText(file);
+        assertEquals(text, extracted.trim());
+    }
+
     private void validateCIDFontType2(boolean useSubset) throws Exception
     {
         PDDocument document = new PDDocument();



Mime
View raw message