pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1741292 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
Date Wed, 27 Apr 2016 17:22:53 GMT
Author: tilman
Date: Wed Apr 27 17:22:52 2016
New Revision: 1741292

URL: http://svn.apache.org/viewvc?rev=1741292&view=rev
Log:
PDFBOX-3280: create a test that fails

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java?rev=1741292&r1=1741291&r2=1741292&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java Wed Apr
27 17:22:52 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.pdmodel;
 
+import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -33,6 +34,8 @@ import junit.framework.TestCase;
 import static junit.framework.TestCase.assertNull;
 import static junit.framework.TestCase.assertTrue;
 import static junit.framework.TestCase.fail;
+import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
+import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 
 /**
  * Testcase introduced with PDFBOX-1581.
@@ -250,4 +253,27 @@ public class TestPDDocument extends Test
         boolean deleted = f.delete();
         assertTrue("delete good file failed after successful load() and close()", deleted);
     }
+    
+    /**
+     * Test whether importPage does a deep copy (if not, the save would fail, see PDFBOX-3328)
+     *
+     * @throws java.io.IOException
+     */
+    public void testImportPage() throws IOException
+    {
+        PDDocument doc1 = new PDDocument();
+        PDPage page = new PDPage();
+        PDPageContentStream pageContentStream = new PDPageContentStream(doc1, page);
+        BufferedImage bim = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB);
+        PDImageXObject img = LosslessFactory.createFromImage(doc1, bim);
+        pageContentStream.drawImage(img, 0, 0);
+        pageContentStream.close();
+        doc1.addPage(page);
+
+        PDDocument doc2 = new PDDocument();
+        doc2.importPage(doc1.getPage(0));
+        doc1.close();
+        doc2.save(new ByteArrayOutputStream());
+        doc2.close();
+    }
 }



Mime
View raw message