PDF rendering using Canvas or PixelBuffer
Michael Paus
mp at jugs.org
Wed Apr 7 16:23:38 UTC 2021
This is probably not the right place to discuss such issues. Stackoverflow
might be better suited. But while we are at it there are a few issues you
might want to look at. Initially I had similar problems like you but then
I found that they were mostly caused by rendering too large images.
Set the output size for the PDF renderer so that it has the same size
as your Canvas, so that you do not render huge images which are lated
just reduced to the desired output size by the ImageView.
Am 07.04.21 um 15:22 schrieb Andrea Vacondio:
> Hi,
> I hope this is the right channel, I'm creating a PDF tool where users can
> see thumbnails of the pages of a PDF file and do things on them (rotate,
> move, select, delete..). Pages are currently laid out in a Flow panel and I
> am evaluating different options to render them and so far I tried:
> 1 - PixelBuffer pretty much like it's used here
> https://github.com/mipastgt/JFXToolsAndDemos/blob/master/jfxtools-awtimage/src/main/java/de/mpmediasoft/jfxtools/awtimage/AWTImage.java
> 2 - Canvas using https://github.com/jfree/fxgraphics2d
>
> In both cases I used SAMBox https://github.com/torakiki/sambox a PDFBox
> fork, to render the pages (I can share more details if needed).
> I tried to profile both approaches and there is an order of magnitude in
> terms of memory consumption. Rendering a 300 pages file I get 700mb of heap
> used with the PixelBuffer approach and 60mb with the canvas. Moreover using
> the PixelBuffer implementation the application starts to do the robot dance
> and when I try to move the mouse around it moves in snaps with a
> considerable lag. With the Canvas impl everything is super responsive.
>
> I know others have experience with PDF rendering with JavaFX and maybe can
> share some thoughts on this. Currently the PixelBuffer impl is unusable for
> me and I'm trying to figure out if I'm doing something wrong or if these
> results are somehow expected.. or maybe there is a bug somewhere.
> Thanks
> Andrea
More information about the openjfx-discuss
mailing list