pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1601565 - in /pdfbox/trunk/pdfbox/src/test: java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg3.tif
Date Tue, 10 Jun 2014 07:45:02 GMT
Author: tilman
Date: Tue Jun 10 07:45:01 2014
New Revision: 1601565

URL: http://svn.apache.org/r1601565
Log:
PDFBOX-934: added a test for CITT G3 compressed TIFFs

Added:
    pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg3.tif
  (with props)
Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java?rev=1601565&r1=1601564&r2=1601565&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/CCITTFactoryTest.java
Tue Jun 10 07:45:01 2014
@@ -56,14 +56,40 @@ public class CCITTFactoryTest extends Te
      */
     public void testCreateFromRandomAccessSingle() throws IOException
     {
-        String tiffPath = "src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif";
+        String tiffG3Path = "src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg3.tif";
+        String tiffG4Path = "src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg4.tif";
         
         PDDocument document = new PDDocument();
-        RandomAccess reader = new RandomAccessFile(new File(tiffPath), "r");
-        PDImageXObject ximage = CCITTFactory.createFromRandomAccess(document, reader);
-        validate(ximage, 1, 344, 287, "tiff", PDDeviceGray.INSTANCE.getName());
+        RandomAccess reader = new RandomAccessFile(new File(tiffG3Path), "r");
+        PDImageXObject ximage3 = CCITTFactory.createFromRandomAccess(document, reader);
+        validate(ximage3, 1, 344, 287, "tiff", PDDeviceGray.INSTANCE.getName());
+        BufferedImage bim3 = ImageIO.read(new File(tiffG3Path));
+        checkIdent(bim3, ximage3.getOpaqueImage());
+        PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+        document.addPage(page);
+        PDPageContentStream contentStream = new PDPageContentStream(document, page, true,
false);
+        contentStream.drawXObject(ximage3, 0, 0, ximage3.getWidth(), ximage3.getHeight());
+        contentStream.close();
+
+        reader = new RandomAccessFile(new File(tiffG4Path), "r");
+        PDImageXObject ximage4 = CCITTFactory.createFromRandomAccess(document, reader);
+        validate(ximage4, 1, 344, 287, "tiff", PDDeviceGray.INSTANCE.getName());
+        BufferedImage bim4 = ImageIO.read(new File(tiffG3Path));
+        checkIdent(bim4, ximage4.getOpaqueImage());
+        page = new PDPage(PDPage.PAGE_SIZE_A4);
+        document.addPage(page);
+        contentStream = new PDPageContentStream(document, page, true, false);
+        contentStream.drawXObject(ximage4, 0, 0, ximage4.getWidth(), ximage4.getHeight());
+        contentStream.close();
+       
+        document.save(testResultsDir + "/singletiff.pdf");
+        document.close();
         
-        doWritePDF(document, ximage, testResultsDir, "singletiff.pdf");
+        document = PDDocument.loadNonSeq(new File(testResultsDir, "singletiff.pdf"), null);
+        List pages = document.getDocumentCatalog().getAllPages();
+        assertEquals(2, pages.size());
+        
+        document.close();  
     }
     
     /**

Added: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg3.tif
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg3.tif?rev=1601565&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/graphics/image/ccittg3.tif
------------------------------------------------------------------------------
    svn:mime-type = image/tiff



Mime
View raw message