You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2015/04/10 20:34:01 UTC

svn commit: r1672724 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/rendering/ examples/src/main/resources/org/apache/pdfbox/examples/rendering/ pdfbox/src/main/java/org/apache/pdfbox/contentstream/ pdfbox/src/main/java/org/apach...

Author: jahewson
Date: Fri Apr 10 18:34:00 2015
New Revision: 1672724

URL: http://svn.apache.org/r1672724
Log:
PDFBOX-2692: Added a robust subclassing API to PageDrawer

Added:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java   (with props)
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java   (with props)
    pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/examples/rendering/
    pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/examples/rendering/custom-render-demo.pdf   (with props)
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawerParameters.java   (with props)
Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Added: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java?rev=1672724&view=auto
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java (added)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java Fri Apr 10 18:34:00 2015
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.examples.rendering;
+
+import java.awt.geom.Point2D;
+import java.io.File;
+import java.io.IOException;
+import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
+import org.apache.pdfbox.contentstream.PDFStreamEngine;
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.graphics.image.PDImage;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.util.Matrix;
+import org.apache.pdfbox.util.Vector;
+
+/**
+ * Example of a custom PDFGraphicsStreamEngine subclass. Allows text and graphics to be processed
+ * in a custom manner. This example simply prints the operations to stdout.
+ *
+ * <p>See {@link PDFStreamEngine} for further methods which may be overridden.
+ * 
+ * @author John Hewson
+ */
+public class CustomGraphicsStreamEngine extends PDFGraphicsStreamEngine
+{
+    public static void main(String[] args) throws IOException
+    {
+        File file = new File("src/main/resources/org/apache/pdfbox/examples/rendering/",
+                             "custom-render-demo.pdf");
+
+        PDDocument doc = PDDocument.load(file);
+        PDPage page = doc.getPage(0);
+        CustomGraphicsStreamEngine engine = new CustomGraphicsStreamEngine(page);
+        engine.run();
+        doc.close();
+    }
+    
+    /**
+     * Constructor.
+     *
+     * @param page PDF Page
+     */
+    protected CustomGraphicsStreamEngine(PDPage page)
+    {
+        super(page);
+    }
+
+    /**
+     * Runs the engine on the current page.
+     *
+     * @throws IOException If there is an IO error while drawing the page.
+     */
+    public void run() throws IOException
+    {
+        processPage(getPage());
+
+        for (PDAnnotation annotation : getPage().getAnnotations())
+        {
+            showAnnotation(annotation);
+        }
+    }
+    
+    @Override
+    public void appendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3) throws IOException
+    {
+        System.out.printf("appendRectangle %.2f %.2f, %.2f %.2f, %.2f %.2f, %.2f %.2f\n",
+                p0.getX(), p0.getY(), p1.getX(), p1.getY(),
+                p2.getX(), p2.getY(), p3.getX(), p3.getY());
+    }
+
+    @Override
+    public void drawImage(PDImage pdImage) throws IOException
+    {
+        System.out.println("drawImage");
+    }
+
+    @Override
+    public void clip(int windingRule) throws IOException
+    {
+        System.out.println("clip");
+    }
+
+    @Override
+    public void moveTo(float x, float y) throws IOException
+    {
+        System.out.printf("moveTo %.2f %.2f\n", x, y);
+    }
+
+    @Override
+    public void lineTo(float x, float y) throws IOException
+    {
+        System.out.printf("lineTo %.2f %.2f\n", x, y);
+    }
+
+    @Override
+    public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) throws IOException
+    {
+        System.out.printf("curveTo %.2f %.2f, %.2f %.2f, %.2f %.2f\n", x1, y1, x2, y2, x3, y3);
+    }
+
+    @Override
+    public Point2D getCurrentPoint() throws IOException
+    {
+        // if you want to build paths, you'll need to keep track of this like PageDrawer does
+        return new Point2D.Float(0, 0);
+    }
+
+    @Override
+    public void closePath() throws IOException
+    {
+        System.out.println("closePath");
+    }
+
+    @Override
+    public void endPath() throws IOException
+    {
+        System.out.println("endPath");
+    }
+
+    @Override
+    public void strokePath() throws IOException
+    {
+        System.out.println("strokePath");
+    }
+
+    @Override
+    public void fillPath(int windingRule) throws IOException
+    {
+        System.out.println("fillPath");
+    }
+
+    @Override
+    public void fillAndStrokePath(int windingRule) throws IOException
+    {
+        System.out.println("fillAndStrokePath");
+    }
+
+    @Override
+    public void shadingFill(COSName shadingName) throws IOException
+    {
+        System.out.println("shadingFill " + shadingName.toString());
+    }
+
+    /**
+     * Overridden from PDFStreamEngine.
+     */
+    @Override
+    public void showTextString(byte[] string) throws IOException
+    {
+        System.out.print("showTextString \"");
+        super.showTextString(string);
+        System.out.println("\"");
+    }
+
+    /**
+     * Overridden from PDFStreamEngine.
+     */
+    @Override
+    public void showTextStrings(COSArray array) throws IOException
+    {
+        System.out.print("showTextStrings \"");
+        super.showTextStrings(array);
+        System.out.println("\"");
+    }
+
+    /**
+     * Overridden from PDFStreamEngine.
+     */
+    @Override
+    protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,
+                             Vector displacement) throws IOException
+    {
+        System.out.print(unicode);
+        super.showGlyph(textRenderingMatrix, font, code, unicode, displacement);
+    }
+    
+    // NOTE: there are may more methods in PDFStreamEngine which can be overridden here too.
+}

Propchange: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java?rev=1672724&view=auto
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java (added)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java Fri Apr 10 18:34:00 2015
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.examples.rendering;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.rendering.PDFRenderer;
+import org.apache.pdfbox.rendering.PageDrawer;
+import org.apache.pdfbox.rendering.PageDrawerParameters;
+import org.apache.pdfbox.util.Matrix;
+import org.apache.pdfbox.util.Vector;
+
+/**
+ * Example showing custom rendering by subclassing PageDrawer.
+ * 
+ * <p>If you want to do custom graphics processing rather than Graphics2D rendering, then you should
+ * subclass {@link PDFGraphicsStreamEngine} instead. Subclassing PageDrawer is only suitable for
+ * cases where the goal is to render onto a Graphics2D surface.
+ *
+ * @author John Hewson
+ */
+public class CustomPageDrawer
+{
+    public static void main(String[] args) throws IOException
+    {
+        File file = new File("src/main/resources/org/apache/pdfbox/examples/rendering/",
+                             "custom-render-demo.pdf");
+        
+        PDDocument doc = PDDocument.load(file);
+        PDFRenderer renderer = new MyPDFRenderer(doc);
+        BufferedImage image = renderer.renderImage(0);
+        ImageIO.write(image, "PNG", new File("custom-render.png"));
+        doc.close();
+    }
+
+    /**
+     * Example PDFRenderer subclass, uses MyPageDrawer for custom rendering.
+     */
+    private static class MyPDFRenderer extends PDFRenderer
+    {
+        public MyPDFRenderer(PDDocument document)
+        {
+            super(document);
+        }
+
+        @Override
+        protected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException
+        {
+            return new MyPageDrawer(parameters);
+        }
+    }
+
+    /**
+     * Example PageDrawer subclass with custom rendering.
+     */
+    private static class MyPageDrawer extends PageDrawer
+    {
+        public MyPageDrawer(PageDrawerParameters parameters) throws IOException
+        {
+            super(parameters);
+        }
+
+        /**
+         * Color replacement.
+         */
+        @Override
+        protected Paint getPaint(PDColor color) throws IOException
+        {
+            // if this is the non-stroking color
+            if (getGraphicsState().getNonStrokingColor() == color)
+            {
+                // find red, ignoring alpha channel
+                if (color.toRGB() == (Color.RED.getRGB() & 0x00FFFFFF))
+                {
+                    // replace it with blue
+                    return Color.BLUE;
+                }
+            }
+            return super.getPaint(color);
+        }
+
+        /**
+         * Glyph bounding boxes.
+         */
+        @Override
+        protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,
+                                 Vector displacement) throws IOException
+        {
+            // draw glyph
+            super.showGlyph(textRenderingMatrix, font, code, unicode, displacement);
+            
+            // bbox in EM -> user units
+            Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1);
+            AffineTransform at = textRenderingMatrix.createAffineTransform();
+            bbox = at.createTransformedShape(bbox);
+            
+            // save
+            Graphics2D graphics = getGraphics();
+            Color color = graphics.getColor();
+            Stroke stroke = graphics.getStroke();
+            Shape clip = graphics.getClip();
+
+            // draw
+            graphics.setClip(graphics.getDeviceConfiguration().getBounds());
+            graphics.setColor(Color.RED);
+            graphics.setStroke(new BasicStroke(.5f));
+            graphics.draw(bbox);
+
+            // restore
+            graphics.setStroke(stroke);
+            graphics.setColor(color);
+            graphics.setClip(clip);
+        }
+
+        /**
+         * Filled path bounding boxes.
+         */
+        @Override
+        public void fillPath(int windingRule) throws IOException
+        {
+            // bbox in user units
+            Shape bbox = getLinePath().getBounds2D();
+            
+            // draw path (note that getLinePath() is now reset)
+            super.fillPath(windingRule);
+            
+            // save
+            Graphics2D graphics = getGraphics();
+            Color color = graphics.getColor();
+            Stroke stroke = graphics.getStroke();
+            Shape clip = graphics.getClip();
+
+            // draw
+            graphics.setClip(graphics.getDeviceConfiguration().getBounds());
+            graphics.setColor(Color.GREEN);
+            graphics.setStroke(new BasicStroke(.5f));
+            graphics.draw(bbox);
+
+            // restore
+            graphics.setStroke(stroke);
+            graphics.setColor(color);
+            graphics.setClip(clip);
+        }
+
+        /**
+         * Custom annotation rendering.
+         */
+        @Override
+        public void showAnnotation(PDAnnotation annotation) throws IOException
+        {
+            // save
+            saveGraphicsState();
+            
+            // 35% alpha
+            getGraphicsState().setNonStrokeAlphaConstants(0.35);
+            super.showAnnotation(annotation);
+            
+            // restore
+            restoreGraphicsState();
+        }
+    }
+}

Propchange: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomPageDrawer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/examples/rendering/custom-render-demo.pdf
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/examples/rendering/custom-render-demo.pdf?rev=1672724&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/examples/rendering/custom-render-demo.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/pdf

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java?rev=1672724&r1=1672723&r2=1672724&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java Fri Apr 10 18:34:00 2015
@@ -68,7 +68,7 @@ import org.apache.pdfbox.contentstream.o
  * 
  * @author Ben Litchfield
  */
-public class PDFStreamEngine
+public abstract class PDFStreamEngine
 {
     private static final Log LOG = LogFactory.getLog(PDFStreamEngine.class);
 
@@ -87,7 +87,7 @@ public class PDFStreamEngine
     /**
      * Creates a new PDFStreamEngine.
      */
-    public PDFStreamEngine()
+    protected PDFStreamEngine()
     {
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java?rev=1672724&r1=1672723&r2=1672724&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java Fri Apr 10 18:34:00 2015
@@ -199,7 +199,17 @@ public class PDFRenderer
             graphics.rotate((float) Math.toRadians(rotationAngle));
         }
 
-        PageDrawer drawer = new PageDrawer(page);
+        // the end-user may provide a custom PageDrawer
+        PageDrawerParameters parameters = new PageDrawerParameters(this, page);
+        PageDrawer drawer = createPageDrawer(parameters);
         drawer.drawPage(graphics, cropBox);
     }
+
+    /**
+     * Returns a new PageDrawer instance, using the given parameters. May be overridden.
+     */
+    protected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException
+    {
+        return new PageDrawer(parameters);
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1672724&r1=1672723&r2=1672724&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Fri Apr 10 18:34:00 2015
@@ -40,7 +40,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.font.PDCIDFontType0;
 import org.apache.pdfbox.pdmodel.font.PDCIDFontType2;
@@ -68,20 +67,28 @@ import org.apache.pdfbox.util.Matrix;
 import org.apache.pdfbox.util.Vector;
 
 /**
- * Paints a page in a PDF document to a Graphics context.
+ * Paints a page in a PDF document to a Graphics context. May be subclassed to provide custom
+ * rendering.
+ * 
+ * <p>If you want to do custom graphics processing rather than Graphics2D rendering, then you should
+ * subclass PDFGraphicsStreamEngine instead. Subclassing PageDrawer is only suitable for cases
+ * where the goal is to render onto a Graphics2D surface.
  * 
  * @author Ben Litchfield
  */
-public final class PageDrawer extends PDFGraphicsStreamEngine
+public class PageDrawer extends PDFGraphicsStreamEngine
 {
     private static final Log LOG = LogFactory.getLog(PageDrawer.class);
 
+    // parent document renderer - note: this is needed for not-yet-implemented resource caching
+    private final PDFRenderer renderer;
+    
     // the graphics device to draw to, xform is the initial transform of the device (i.e. DPI)
     private Graphics2D graphics;
     private AffineTransform xform;
 
     // the page box to draw (usually the crop box but may be another)
-    PDRectangle pageSize;
+    private PDRectangle pageSize;
     
     // clipping winding rule used for the clipping path
     private int clipWindingRule = -1;
@@ -93,17 +100,43 @@ public final class PageDrawer extends PD
     // buffered clipping area for text being drawn
     private Area textClippingArea;
 
+    // glyph cache
     private final Map<PDFont, Glyph2D> fontGlyph2D = new HashMap<PDFont, Glyph2D>();
     
     /**
      * Constructor.
-     * 
-     * @param page the page that is to be rendered.
+     *
+     * @param parameters Parameters for page drawing.
      * @throws IOException If there is an error loading properties from the file.
      */
-    public PageDrawer(PDPage page) throws IOException
+    public PageDrawer(PageDrawerParameters parameters) throws IOException
+    {
+        super(parameters.getPage());
+        this.renderer = parameters.getRenderer();
+    }
+
+    /**
+     * Returns the parent renderer.
+     */
+    public final PDFRenderer getRenderer()
+    {
+        return renderer;
+    }
+
+    /**
+     * Returns the underlying Graphics2D. May be null if drawPage has not yet been called.
+     */
+    protected final Graphics2D getGraphics()
+    {
+        return graphics;
+    }
+
+    /**
+     * Returns the current line path. This is reset to empty after each fill/stroke.
+     */
+    protected final GeneralPath getLinePath()
     {
-        super(page);
+        return linePath;
     }
 
     /**
@@ -163,7 +196,7 @@ public final class PageDrawer extends PD
      * @param patternMatrix the pattern matrix
      * @throws IOException If there is an IO error while drawing the page.
      */
-    public void drawTilingPattern(Graphics2D g, PDTilingPattern pattern, PDColorSpace colorSpace,
+    void drawTilingPattern(Graphics2D g, PDTilingPattern pattern, PDColorSpace colorSpace,
                                   PDColor color, Matrix patternMatrix) throws IOException
     {
         Graphics2D oldGraphics = graphics;
@@ -186,7 +219,7 @@ public final class PageDrawer extends PD
     /**
      * Returns an AWT paint for the given PDColor.
      */
-    private Paint getPaint(PDColor color) throws IOException
+    protected Paint getPaint(PDColor color) throws IOException
     {
         PDColorSpace colorSpace = color.getColorSpace();
         if (!(colorSpace instanceof PDPattern))
@@ -696,8 +729,7 @@ public final class PageDrawer extends PD
         if (pdImage.isStencil())
         {
             // fill the image with paint
-            PDColor color = getGraphicsState().getNonStrokingColor();
-            BufferedImage image = pdImage.getStencilImage(getPaint(color));
+            BufferedImage image = pdImage.getStencilImage(getNonStrokingPaint());
 
             // draw the image
             drawBufferedImage(image, at);
@@ -716,7 +748,7 @@ public final class PageDrawer extends PD
         }
     }
 
-    public void drawBufferedImage(BufferedImage image, AffineTransform at) throws IOException
+    private void drawBufferedImage(BufferedImage image, AffineTransform at) throws IOException
     {
         graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite());
         setClip();

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawerParameters.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawerParameters.java?rev=1672724&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawerParameters.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawerParameters.java Fri Apr 10 18:34:00 2015
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.rendering;
+
+import org.apache.pdfbox.pdmodel.PDPage;
+
+/**
+ * Parameters for a PageDrawer. This class ensures allows PDFRenderer and PageDrawer to share
+ * private implementation data in a future-proof manner, while still allowing end-users to create
+ * their own subclasses of PageDrawer.
+ * 
+ * @author John Hewson
+ */
+public final class PageDrawerParameters
+{
+    private final PDFRenderer renderer;
+    private final PDPage page;
+
+    /**
+     * Package-private constructor.
+     */
+    PageDrawerParameters(PDFRenderer renderer, PDPage page)
+    {
+        this.renderer = renderer;
+        this.page = page;
+    }
+
+    /**
+     * Returns the page.
+     */
+    public PDPage getPage()
+    {
+        return page;
+    }
+    
+    /**
+     * Returns the renderer.
+     */
+    PDFRenderer getRenderer()
+    {
+        return renderer;
+    }
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawerParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native