pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1749146 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
Date Sun, 19 Jun 2016 10:21:07 GMT
Author: tilman
Date: Sun Jun 19 10:21:07 2016
New Revision: 1749146

URL: http://svn.apache.org/viewvc?rev=1749146&view=rev
Log:
PDFBOX-3337: added test code from Philip Helger

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

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java?rev=1749146&r1=1749145&r2=1749146&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
Sun Jun 19 10:21:07 2016
@@ -19,8 +19,14 @@
 
 package org.apache.pdfbox.pdmodel.font;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import junit.framework.TestCase;
 import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.rendering.PDFRenderer;
 
 /**
@@ -51,4 +57,34 @@ public class PDFontTest extends TestCase
             }
         }
     }
+
+    /**
+     * PDFBOX-3337: Test ability to reuse a TrueTypeFont for several PDFs to avoid parsing
it over
+     * and over again.
+     *
+     * @throws java.io.IOException
+     */
+    public void testPDFBox3337() throws IOException
+    {
+        InputStream ttfStream = PDFontTest.class.getClassLoader().getResourceAsStream(
+                "org/apache/pdfbox/ttf/LiberationSans-Regular.ttf");
+
+        for (int i = 0; i < 2; ++i)
+        {
+            PDDocument doc = new PDDocument();
+
+            final PDPage page = new PDPage(PDRectangle.A4);
+            doc.addPage(page);
+
+            PDPageContentStream cs = new PDPageContentStream(doc, page);
+            PDFont font = PDType0Font.load(doc, ttfStream);
+            cs.setFont(font, 10);
+            cs.beginText();
+            cs.showText("PDFBOX");
+            cs.endText();
+            cs.close();
+            doc.save(new ByteArrayOutputStream());
+            doc.close();
+        }
+    }
 }



Mime
View raw message