[ 
https://issues.apache.org/jira/browse/PDFBOX-1444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Hewson closed PDFBOX-1444.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 2.0.0

We fixed this in 2.0 in a different way. There's a new PDFGraphicsStreamEngine 
class which can be subclasses in order to gain access to graphics. PageDrawer 
itself in now completely internal to PDFBox.

> Capability to use custom PageDrawer in PDPage.convertToImage
> ------------------------------------------------------------
>
>                 Key: PDFBOX-1444
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1444
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel, Rendering
>    Affects Versions: 1.8.0
>         Environment: Ubuntu 11.10 64 bit on Intel® Core™ i5-2430M CPU. Sun 
> JDK "1.6.0_30" (build 1.6.0_30-b12) Java HotSpot(TM) 64-Bit Server VM (build 
> 20.5-b03, mixed mode).
>            Reporter: Ravi Hegde
>             Fix For: 2.0.0
>
>
> Extending PageDrawer is a handy technique for PDF processing tools to get 
> information about the  elements drawn on the page while drawing the page in 
> one go. However, PDPage.convertToImage has no way of plugging in the extended 
> PageDrawer class. It is necessary to provide some way to use custom 
> PageDrawer instance in PDPage.convertToImage. Overloaded 
> PDPage.convertToImage with a PageDrawer instance may be a good option. Here 
> is the patch:
> svn diff PDPage.java
> Index: PDPage.java
> ===================================================================
> --- PDPage.java       (revision 1407714)
> +++ PDPage.java       (working copy)
> @@ -699,6 +699,24 @@
>       */
>      public BufferedImage convertToImage(int imageType, int resolution) 
> throws IOException
>      {
> +        PageDrawer drawer = new PageDrawer();
> +        return convertToImage(imageType, resolution, drawer);
> +    }
> +
> +    /**
> +     * Convert this page to an output image using custom PageDrawer 
> instance. 
> +     * Custom page drawer is useful for collecting information about the 
> +     * elements drawn on the page while drawing the page.
> +     * 
> +     * @param imageType the image type (see {@link BufferedImage}.TYPE_*)
> +     * @param resolution the resolution in dpi (dots per inch)
> +     * @param drawer Custom {@link PageDrawer} instance.
> +     * @return A graphical representation of this page.
> +     *
> +     * @throws IOException If there is an error drawing to the image.
> +     */
> +    public BufferedImage convertToImage(int imageType, int resolution, 
> PageDrawer drawer) throws IOException
> +    {
>          PDRectangle cropBox = findCropBox();
>          float widthPt = cropBox.getWidth();
>          float heightPt = cropBox.getHeight();
> @@ -753,7 +771,6 @@
>              graphics.rotate((float)Math.toRadians(rotationAngle));
>          }
>          graphics.scale( scaling, scaling );
> -        PageDrawer drawer = new PageDrawer();
>          drawer.drawPage( graphics, this, pageDimension );
>  
>          return retval;



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to