Hi,
Am 27.02.2013 10:37, schrieb Jon Doe:
Hey Guys!
I've got an issue with PDFBox.
I want to create a PDF about, let's say, 100 pages and every page contains
an Image (I got the images from a .tiff file and decoded them to PNG).
After about fifty pages I get an OutOfMemoryException from my Java runtime
and
the application terminates - do you have an idea how I get rid of this? I
tried for days
to find a useable solution, but it's not that successive as I expected.
I don't want to reserve 2GiB of RAM space just for a Tiif to PDF
conversion, so have
you any ideas how I could continue my work?
Hmm, I can imagine several reasons for that
- a huge pdf needs at least more memory than smaller ones
- your application didn't free resources when they aren't needed anymore
- your images are using a very huge resolution
- ....
I already tried the .saveIncremental() methods, looked for page
compression, extended the
Heapspace with -Xmx1024M and did a few other things but it still isn't
working.
Incremental saving isn't supposed to be used in that context.
It'd be great to hearing from you, thank you in advance!
Depending on the "real" reason for your issue, there are different possible
solutions/worksarounds
- optimize your code
- reduce the resolution of the images
- split up your pdfs, lets say into pieces of 10 pages each and merge those
pieces using the PDFMergerUtility provided by PDFBox into one huge pdf
Regards,
Kai Oliver
BR
Andreas Lehmkühler