Author: ssteiner
Date: Fri Jul  7 13:52:21 2017
New Revision: 1801164

URL: http://svn.apache.org/viewvc?rev=1801164&view=rev
Log:
FOP-2720: PDF to PCL exception on clipping

Modified:
    
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/ImageConverterPDF2G2D.java
    
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java

Modified: 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/ImageConverterPDF2G2D.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/ImageConverterPDF2G2D.java?rev=1801164&r1=1801163&r2=1801164&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/ImageConverterPDF2G2D.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/ImageConverterPDF2G2D.java
 Fri Jul  7 13:52:21 2017
@@ -147,6 +147,8 @@ public class ImageConverterPDF2G2D exten
                         area.getHeight() / mediaBox.getHeight());
                 g2d.transform(at);
                 new PDFRenderer(pdDocument).renderPageToGraphics(selectedPage, 
g2d);
+            } catch (UnsupportedOperationException e) {
+                throw e;
             } catch (Throwable t) {
                 throw new RuntimeException("Error while painting PDF page: " + 
uri + " " + t.getMessage(), t);
             }

Modified: 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java?rev=1801164&r1=1801163&r2=1801164&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
 Fri Jul  7 13:52:21 2017
@@ -72,6 +72,8 @@ import org.apache.fop.pdf.PDFGState;
 import org.apache.fop.pdf.PDFPage;
 import org.apache.fop.pdf.PDFResources;
 import org.apache.fop.pdf.PDFStream;
+import org.apache.fop.render.pcl.PCLGenerator;
+import org.apache.fop.render.pcl.PCLGraphics2D;
 import org.apache.fop.render.pdf.pdfbox.ImageConverterPDF2G2D;
 import org.apache.fop.render.pdf.pdfbox.ImagePDF;
 import org.apache.fop.render.pdf.pdfbox.PDFBoxAdapter;
@@ -359,6 +361,32 @@ public class PDFBoxAdapterTestCase {
         return stream;
     }
 
+    @Test
+    public void testPCL() throws IOException, ImageException {
+        String ex = "";
+        try {
+            pdfToPCL(SHADING);
+        } catch (UnsupportedOperationException e) {
+            ex = e.getMessage();
+        }
+        Assert.assertTrue(ex.contains("Clipping is not supported."));
+    }
+
+    private void pdfToPCL(String pdf) throws IOException, ImageException {
+        ImageConverterPDF2G2D i = new ImageConverterPDF2G2D();
+        ImageInfo imgi = new ImageInfo(pdf, "b");
+        PDDocument doc = PDDocument.load(new File(pdf));
+        org.apache.xmlgraphics.image.loader.Image img = new ImagePDF(imgi, 
doc);
+        ImageGraphics2D ig = (ImageGraphics2D)i.convert(img, null);
+        ByteArrayOutputStream stream = new ByteArrayOutputStream();
+        PCLGraphics2D g2d = new PCLGraphics2D(new PCLGenerator(stream));
+        Rectangle2D rect = new Rectangle2D.Float(0, 0, 100, 100);
+        GraphicContext gc = new GraphicContext();
+        g2d.setGraphicContext(gc);
+        ig.getGraphics2DImagePainter().paint(g2d, rect);
+        doc.close();
+    }
+
     static class FOPPSGeneratorImpl extends PSGenerator implements 
PSDocumentHandler.FOPPSGenerator {
         public FOPPSGeneratorImpl(OutputStream out) {
             super(out);



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to