You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Markus Barbey <Ba...@gmx.de> on 2016/09/07 15:02:27 UTC
PageDrawer and partial rendering - skip invisible parts when
rendering
Hello there,
when using
PDFRender#renderPageToGraphics(int, Graphics2D)
you can set an AffineTransform (e.G. scale and translate) in the Graphics2D instance which results in a partially rendered PDF page. Nevertheless each resource gets rendered by the renderer - even if it is not visible in the resulting BufferedImage.
For example: PDF original size 800x600
--------------------------------------------
BufferedImage image = new BufferedImage (400, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics ();
AffineTransform tx = new AffineTransform ();
tx.translate (200,300);
tx.scale (2, 2);
graphics.setTransform (tx);
renderer.renderPageToGraphics (0, graphics);
graphics.dispose ();
--------------------------------------------
When you have some large images (e.G. high DPI logo and charts) on a single PDF page there could be a great performance boost for partial rendering (that is mainly required in PDF viewer controls), if images, that are not going to be visible in the resulting BufferedImage skipped while drawing. Nowadays they are converted to a BufferedImage (which can last remarkable time) and drawn to the Graphics2D. Due to size and clipping configuration they are not visible in the resulting BufferedImage.
Cu
Markus
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PageDrawer and partial rendering - skip invisible parts when
rendering
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 07.09.2016 um 17:02 schrieb Markus Barbey:
> Hello there,
>
> when using
>
> PDFRender#renderPageToGraphics(int, Graphics2D)
>
> you can set an AffineTransform (e.G. scale and translate) in the Graphics2D instance which results in a partially rendered PDF page. Nevertheless each resource gets rendered by the renderer - even if it is not visible in the resulting BufferedImage.
>
> For example: PDF original size 800x600
>
> --------------------------------------------
>
> BufferedImage image = new BufferedImage (400, 200, BufferedImage.TYPE_INT_RGB);
> Graphics2D graphics = image.createGraphics ();
>
> AffineTransform tx = new AffineTransform ();
> tx.translate (200,300);
> tx.scale (2, 2);
> graphics.setTransform (tx);
>
> renderer.renderPageToGraphics (0, graphics);
> graphics.dispose ();
>
> --------------------------------------------
>
> When you have some large images (e.G. high DPI logo and charts) on a single PDF page there could be a great performance boost for partial rendering (that is mainly required in PDF viewer controls), if images, that are not going to be visible in the resulting BufferedImage skipped while drawing. Nowadays they are converted to a BufferedImage (which can last remarkable time) and drawn to the Graphics2D. Due to size and clipping configuration they are not visible in the resulting BufferedImage.
Feel free to make a patch for PageDrawer.drawImage that checks whether
the image will be outside... Be aware that both images and the xform can
be rotated.
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PageDrawer and partial rendering - skip invisible parts when rendering
Posted by John Hewson <jo...@jahewson.com>.
> On 7 Sep 2016, at 08:02, Markus Barbey <Ba...@gmx.de> wrote:
>
> Hello there,
>
> when using
>
> PDFRender#renderPageToGraphics(int, Graphics2D)
>
> you can set an AffineTransform (e.G. scale and translate) in the Graphics2D instance which results in a partially rendered PDF page. Nevertheless each resource gets rendered by the renderer - even if it is not visible in the resulting BufferedImage.
>
> For example: PDF original size 800x600
>
> --------------------------------------------
>
> BufferedImage image = new BufferedImage (400, 200, BufferedImage.TYPE_INT_RGB);
> Graphics2D graphics = image.createGraphics ();
>
> AffineTransform tx = new AffineTransform ();
> tx.translate (200,300);
> tx.scale (2, 2);
> graphics.setTransform (tx);
>
> renderer.renderPageToGraphics (0, graphics);
> graphics.dispose ();
>
> --------------------------------------------
>
> When you have some large images (e.G. high DPI logo and charts) on a single PDF page there could be a great performance boost for partial rendering (that is mainly required in PDF viewer controls), if images, that are not going to be visible in the resulting BufferedImage skipped while drawing. Nowadays they are converted to a BufferedImage (which can last remarkable time) and drawn to the Graphics2D. Due to size and clipping configuration they are not visible in the resulting BufferedImage.
I would recommend caching the BufferedImage for an entire rendered page instead and then having your PDF viewer display a portion of that image.
— John
>
>
> Cu
> Markus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org