pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1574811 [2/2] - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/ pdfbox/src/main/java/org/apache/pdfbox/pdmod...
Date Thu, 06 Mar 2014 09:05:09 GMT
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/MoveTo.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/MoveTo.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/MoveTo.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/MoveTo.java
Thu Mar  6 09:05:08 2014
@@ -21,7 +21,7 @@ import java.util.List;
 
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSNumber;
-import org.apache.pdfbox.pdfviewer.PageDrawer;
+import org.apache.pdfbox.rendering.PageDrawer;
 import org.apache.pdfbox.util.PDFOperator;
 import org.apache.pdfbox.util.operator.OperatorProcessor;
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SHFill.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SHFill.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SHFill.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/SHFill.java
Thu Mar  6 09:05:08 2014
@@ -21,7 +21,7 @@ import java.util.List;
 
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdfviewer.PageDrawer;
+import org.apache.pdfbox.rendering.PageDrawer;
 import org.apache.pdfbox.util.PDFOperator;
 import org.apache.pdfbox.util.operator.OperatorProcessor;
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
Thu Mar  6 09:05:08 2014
@@ -19,7 +19,7 @@ package org.apache.pdfbox.util.operator.
 import java.util.List;
 
 import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.pdfviewer.PageDrawer;
+import org.apache.pdfbox.rendering.PageDrawer;
 import org.apache.pdfbox.util.PDFOperator;
 import org.apache.pdfbox.util.operator.OperatorProcessor;
 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDSimpleFontTest.java
Thu Mar  6 09:05:08 2014
@@ -19,11 +19,8 @@
 
 package org.apache.pdfbox.pdmodel.font;
 
-import java.util.List;
-
 import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.util.RenderUtil;
+import org.apache.pdfbox.rendering.PDFRenderer;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -71,9 +68,9 @@ public class PDSimpleFontTest
         try
         {
             doc = PDDocument.load(PDSimpleFontTest.class.getResourceAsStream("F001u_3_7j.pdf"));
-            List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
-            RenderUtil.convertToImage(pages.get(0));
-            // The alligation is that convertToImage() will crash the JVM or hang
+            PDFRenderer renderer = new PDFRenderer(doc);
+            renderer.renderImage(0);
+            // the allegation is that renderImage() will crash the JVM or hang
         }
         finally
         {
@@ -94,9 +91,9 @@ public class PDSimpleFontTest
         try
         {
             doc = PDDocument.load(PDSimpleFontTest.class.getResourceAsStream("256.pdf"));
-            List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
-            RenderUtil.convertToImage(pages.get(0));
-            // The alligation is that convertToImage() will crash the JVM or hang
+            PDFRenderer renderer = new PDFRenderer(doc);
+            renderer.renderImage(0);
+            // the allegation is that renderImage() will crash the JVM or hang
         }
         finally
         {

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java Thu Mar
 6 09:05:08 2014
@@ -20,82 +20,70 @@ import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
-import java.util.List;
 
 import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.rendering.PDFRenderer;
 
 /**
  * Test suite for ImageIOUtil.
- * 
  */
 public class TestImageIOUtils extends TestCase
 {
-
-    /**
-     * Logger instance.
-     */
     private static final Log LOG = LogFactory.getLog(TestImageIOUtils.class);
 
-    private boolean testFailed = false;
-
     /**
      * Validate page rendering for all supported image formats (JDK5).
      * 
      * @param file The file to validate
-     * @param inDir Name of the input directory
      * @param outDir Name of the output directory
      * @throws Exception when there is an exception
      */
-    private void doTestFile(File file, String inDir, String outDir) throws Exception
+    private void doTestFile(File file, String outDir) throws Exception
     {
         PDDocument document = null;
         String imageType = "png";
         LOG.info("Preparing to convert " + file.getName());
         try
         {
-            int resolution = 120;
+            float dpi = 120;
             document = PDDocument.load(file);
             // testing PNG
-            writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_INT_RGB,
resolution);
+            writeImage(document, imageType, outDir + file.getName() + "-", dpi);
             // testing JPG/JPEG
             imageType = "jpg";
-            writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_INT_RGB,
resolution);
+            writeImage(document, imageType, outDir + file.getName() + "-", dpi);
             // testing BMP
             imageType = "bmp";
-            writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_INT_RGB,
resolution);
+            writeImage(document, imageType, outDir + file.getName() + "-", dpi);
             // testing WBMP
             imageType = "wbmp";
-            writeImage(document, imageType, outDir + file.getName() + "-", BufferedImage.TYPE_BYTE_BINARY,
resolution);
+            writeImage(document, imageType, outDir + file.getName() + "-", dpi);
             // testing TIFF
             imageType = "tif";
-            writeImage(document, imageType, outDir + file.getName() + "-bw-", BufferedImage.TYPE_BYTE_BINARY,
resolution);
-            writeImage(document, imageType, outDir + file.getName() + "-co-", BufferedImage.TYPE_INT_RGB,
resolution);
-        }
-        catch (Exception e)
-        {
-            testFailed = true;
-            LOG.error("Error converting file " + file.getName() + " using image type " +
imageType, e);
+            writeImage(document, imageType, outDir + file.getName() + "-bw-", dpi);
+            writeImage(document, imageType, outDir + file.getName() + "-co-", dpi);
         }
         finally
         {
-            document.close();
+            if (document!= null)
+            {
+                document.close();
+            }
         }
-
     }
 
-    private void writeImage(PDDocument document, String imageFormat, String outputPrefix,
int imageType, int resolution)
+    private void writeImage(PDDocument document, String imageFormat, String outputPrefix,
float dpi)
             throws IOException
     {
-        List<PDPage> pages = document.getDocumentCatalog().getAllPages();
-        BufferedImage image = RenderUtil.convertToImage(pages.get(0), imageType, resolution);
+        PDFRenderer renderer = new PDFRenderer(document);
+        BufferedImage image = renderer.renderImage(0, dpi / 72f);
         String fileName = outputPrefix + 1;
         LOG.info("Writing: " + fileName + "." + imageFormat);
-        ImageIOUtil.writeImage(image, imageFormat, fileName, imageType, resolution);
+        ImageIOUtil.writeImage(image, imageFormat, fileName,  Math.round(dpi));
     }
 
     /**
@@ -103,7 +91,6 @@ public class TestImageIOUtils extends Te
      * 
      * @throws Exception when there is an exception
      */
-     
     public void testRenderImage() throws Exception
     {
         String inDir = "src/test/resources/input/ImageIOUtil";
@@ -118,15 +105,9 @@ public class TestImageIOUtils extends Te
             }
         });
 
-        for (int n = 0; n < testFiles.length; n++)
-        {
-            doTestFile(testFiles[n], inDir, outDir);
-        }
-
-        if (testFailed)
+        for (File file : testFiles)
         {
-            fail("One or more failures, see test log for details");
+            doTestFile(file, outDir);
         }
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java Thu Mar 
6 09:05:08 2014
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.util;
 
+import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
@@ -28,6 +29,9 @@ import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.rendering.PDFRenderer;
+
+import javax.imageio.ImageIO;
 
 /**
  * Test suite for PDFTextStripper.
@@ -63,7 +67,7 @@ public class TestPDFToImage extends Test
     private static final Log log = LogFactory.getLog(TestPDFToImage.class);
 
     private boolean bFail = false;
-    private PDFImageWriter writer = null;
+    private PDFRenderer renderer = null;
     private File mcurFile = null;
 
     /**
@@ -76,7 +80,6 @@ public class TestPDFToImage extends Test
     public TestPDFToImage( String name ) throws IOException
     {
         super( name );
-        writer = new PDFImageWriter();
     }
 
     /**
@@ -108,7 +111,18 @@ public class TestPDFToImage extends Test
         try
         {
             document =  PDDocument.load(file);
-            writer.writeImage(document, "png", "", 1, Integer.MAX_VALUE, outDir + file.getName()
+ "-");
+            renderer = new PDFRenderer(document);
+
+            String outputPrefix = outDir + file.getName() + "-";
+            int numPages = document.getNumberOfPages();
+            PDFRenderer renderer = new PDFRenderer(document);
+            for (int i = 0; i < numPages; i++)
+            {
+                BufferedImage image = renderer.renderImage(i);
+                String fileName = outputPrefix + (i + 1);
+                log.info("Writing: " + fileName + ".pbg");
+                ImageIO.write(image, "PNG", new File(fileName));
+            }
         }
         catch(Exception e)
         { 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestRendering.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestRendering.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestRendering.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestRendering.java Thu Mar  6
09:05:08 2014
@@ -19,7 +19,7 @@ package org.apache.pdfbox.util;
 
 import org.apache.pdfbox.ParallelParameterized;
 import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.rendering.PDFRenderer;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized.Parameters;
@@ -74,8 +74,8 @@ public class TestRendering
     {
         File file = new File(INPUT_DIR, fileName);
         PDDocument document = PDDocument.load(file);
-        List<PDPage> pages = document.getDocumentCatalog().getAllPages();
-        BufferedImage image = RenderUtil.convertToImage(pages.get(0), BufferedImage.TYPE_INT_RGB,
72);
+        PDFRenderer renderer = new PDFRenderer(document);
+        BufferedImage image = renderer.renderImage(0);
 
         // We don't actually do anything with the image for the same reason that
         // TestPDFToImage is disabled - different JVMs produce different results

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java Thu Mar  6 09:05:08
2014
@@ -33,13 +33,13 @@ import javax.swing.JScrollPane;
 import javax.swing.KeyStroke;
 
 import org.apache.pdfbox.exceptions.InvalidPasswordException;
+import org.apache.pdfbox.rendering.PDFPrinter;
+import org.apache.pdfbox.rendering.PDFRenderer;
 import org.apache.pdfbox.tools.gui.PageWrapper;
 import org.apache.pdfbox.tools.gui.ReaderBottomPanel;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDPageable;
 import org.apache.pdfbox.util.ImageIOUtil;
-import org.apache.pdfbox.util.RenderUtil;
 
 /**
  * An proof-of-concept application to read PDF documents, with very basic functionality.
@@ -60,6 +60,7 @@ public class PDFReader extends JFrame
     private JPanel documentPanel = new JPanel();
     private ReaderBottomPanel bottomStatusPanel = new ReaderBottomPanel();
 
+    private PDFRenderer renderer;
     private PDDocument document = null;
     private List<PDPage> pages = null;
 
@@ -129,9 +130,9 @@ public class PDFReader extends JFrame
                 {
                     if (document != null)
                     {
-                        PDPageable pageable = new PDPageable(document);
-                        PrinterJob job = pageable.getPrinterJob();
-                        job.setPageable(pageable);
+                        PDFPrinter printer = new PDFPrinter(document);
+                        PrinterJob job = PrinterJob.getPrinterJob();
+                        job.setPageable(printer.getPageable());
                         if (job.printDialog())
                         {
                             job.print();
@@ -329,7 +330,7 @@ public class PDFReader extends JFrame
         try
         {
             PageWrapper wrapper = new PageWrapper(this);
-            wrapper.displayPage((PDPage) pages.get(pageNumber));
+            wrapper.displayPage(renderer, pages.get(pageNumber));
             if (documentPanel.getComponentCount() > 0)
             {
                 documentPanel.remove(0);
@@ -347,7 +348,8 @@ public class PDFReader extends JFrame
     {
         try
         {
-            BufferedImage pageAsImage = RenderUtil.convertToImage(pages.get(currentPage));
+            PDFRenderer renderer = new PDFRenderer(document);
+            BufferedImage pageAsImage = renderer.renderImage(currentPage);
             String imageFilename = currentFilename;
             if (imageFilename.toLowerCase().endsWith(".pdf"))
             {
@@ -373,6 +375,7 @@ public class PDFReader extends JFrame
         else
         {
             document = PDDocument.load(file);
+            renderer = new PDFRenderer(document);
             if (document.isEncrypted())
             {
                 try

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java Thu Mar  6 09:05:08
2014
@@ -30,7 +30,8 @@ import org.apache.pdfbox.exceptions.Inva
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.util.PDFImageWriter;
+import org.apache.pdfbox.rendering.PDFRenderer;
+import org.apache.pdfbox.util.ImageIOUtil;
 
 /**
  * Convert a PDF document to an image.
@@ -76,18 +77,18 @@ public class PDFToImage
         int startPage = 1;
         int endPage = Integer.MAX_VALUE;
         String color = "rgb";
-        int resolution;
+        int dpi;
         float cropBoxLowerLeftX = 0;
         float cropBoxLowerLeftY = 0;
         float cropBoxUpperRightX = 0;
         float cropBoxUpperRightY = 0;
         try
         {
-            resolution = Toolkit.getDefaultToolkit().getScreenResolution();
+            dpi = Toolkit.getDefaultToolkit().getScreenResolution();
         }
         catch( HeadlessException e )
         {
-            resolution = 96;
+            dpi = 96;
         }
         for( int i = 0; i < args.length; i++ )
         {
@@ -136,7 +137,7 @@ public class PDFToImage
             else if( args[i].equals( RESOLUTION ) )
             {
                 i++;
-                resolution = Integer.parseInt(args[i]);
+                dpi = Integer.parseInt(args[i]);
             }
             else if( args[i].equals( CROPBOX ) )
             {
@@ -241,10 +242,17 @@ public class PDFToImage
                             cropBoxUpperRightX, cropBoxUpperRightY);
                 }
 
-                //Make the call
-                PDFImageWriter imageWriter = new PDFImageWriter();
-                boolean success = imageWriter.writeImage(document, imageFormat, password,
-                        startPage, endPage, outputPrefix, imageType, resolution);
+                // render the pages
+                boolean success = true;
+                int numPages = document.getNumberOfPages();
+                PDFRenderer renderer = new PDFRenderer(document);
+                for (int i = startPage - 1; i < endPage && i < numPages; i++)
+                {
+                    BufferedImage image = renderer.renderImage(i, dpi);
+                    String fileName = outputPrefix + (i + 1);
+                    success &= ImageIOUtil.writeImage(image, imageFormat, fileName, imageType,
dpi);
+                }
+
                 if (!success)
                 {
                     System.err.println( "Error: no writer found for image format '"

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PrintPDF.java Thu Mar  6 09:05:08
2014
@@ -22,7 +22,8 @@ import java.io.File;
 import javax.print.PrintService;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.util.RenderUtil;
+import org.apache.pdfbox.rendering.PDFPrinter;
+import org.apache.pdfbox.rendering.PDFRenderer;
 
 /**
  * This is a command line program that will print a PDF document.
@@ -120,13 +121,14 @@ public class PrintPDF
                 }
             }
 
+            PDFPrinter printer = new PDFPrinter(document);
             if (silentPrint)
             {
-                RenderUtil.silentPrint(document, printJob);
+                printer.silentPrint(printJob);
             }
             else if (printJob.printDialog())
             {
-                RenderUtil.print(document, printJob);
+                printer.print(printJob);
             }
         }
         finally

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFPagePanel.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFPagePanel.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFPagePanel.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFPagePanel.java Thu Mar
 6 09:05:08 2014
@@ -24,7 +24,8 @@ import java.io.IOException;
 
 import javax.swing.JPanel;
 
-import org.apache.pdfbox.pdfviewer.PageDrawer;
+import org.apache.pdfbox.rendering.PDFRenderer;
+import org.apache.pdfbox.rendering.PageDrawer;
 import org.apache.pdfbox.pdmodel.PDPage;
 
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
@@ -37,32 +38,23 @@ import org.apache.pdfbox.pdmodel.common.
  */
 public class PDFPagePanel extends JPanel
 {
-
     private static final long serialVersionUID = -4629033339560890669L;
-    
+
+    private PDFRenderer renderer;
     private PDPage page;
-    private PageDrawer drawer = null;
     private Dimension pageDimension = null;
     private Dimension drawDimension = null;
 
     /**
-     * Constructor.
-     *
-     * @throws IOException If there is an error creating the Page drawing objects.
-     */
-    public PDFPagePanel() throws IOException
-    {
-        drawer = new PageDrawer();
-    }
-
-    /**
      * This will set the page that should be displayed in this panel.
      *
-     * @param pdfPage The page to draw.
+     * @param page The page to draw.
      */
-    public void setPage( PDPage pdfPage )
+    public void setPage( PDFRenderer renderer, PDPage page ) throws IOException
     {
-        page = pdfPage;
+        this.renderer = renderer;
+        this.page = page;
+
         PDRectangle cropBox = page.findCropBox();
         drawDimension = cropBox.createDimension();
         int rotation = page.findRotation();
@@ -85,6 +77,8 @@ public class PDFPagePanel extends JPanel
     {
         try
         {
+            PageDrawer drawer = new PageDrawer(renderer);
+
             g.setColor( getBackground() );
             g.fillRect( 0, 0, getWidth(), getHeight() );
 

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PageWrapper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PageWrapper.java?rev=1574811&r1=1574810&r2=1574811&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PageWrapper.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PageWrapper.java Thu Mar
 6 09:05:08 2014
@@ -18,6 +18,7 @@
 package org.apache.pdfbox.tools.gui;
 
 import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.rendering.PDFRenderer;
 import org.apache.pdfbox.tools.PDFReader;
 
 import javax.swing.JPanel;
@@ -60,9 +61,9 @@ public class PageWrapper implements Mous
      * This will display the PDF page in this component.
      * @param page The PDF page to display.
      */
-    public void displayPage(PDPage page)
+    public void displayPage(PDFRenderer renderer,  PDPage page) throws IOException
     {
-        pagePanel.setPage(page);
+        pagePanel.setPage(renderer, page);
         pagePanel.setPreferredSize(pagePanel.getSize());
         Dimension d = pagePanel.getSize();
         d.width+=(SPACE_AROUND_DOCUMENT*2);



Mime
View raw message