开发者

ABCPdf uses a lot of memory and generates huge files. Solution?

开发者 https://www.devze.com 2023-01-31 15:19 出处:网络
I have a system for creating a pdf book from users own images. The images are in high resolution and the pdf end up with around 70pages with pictures on most of them.

I have a system for creating a pdf book from users own images. The images are in high resolution and the pdf end up with around 70pages with pictures on most of them.

When generating the pdf the in a local application on the server the process uses around 3Gb of ram which makes it crash more often then it succeeds. The files are als开发者_运维技巧o really huge, around 1,2 Gb. Running it through a print to pdf would make it a a hundred times smaller.

Is there a way to make ABCPdf use less memory and creating smaller files?


I have had a very similar experience with iTextSharp, where I was basically running out of memory anytime I create a large PDF with images in it.

I found that there is a function that I should call to release images after I am done with the image, since it holds it in memory in case you want to use it again or until you finally close the PDF.

Either reuse the image if they are repeating header/footer logos, or release images on the go.
Most likely that is the issue you are facing, but I have no experience in ABCPdf.


I've not used ABCPdf directly but I'd suspect that the images are the source of your issues, resize them before they are included in the PDF objects. I suspect that's what a print-to-PDF process will be doing.


One other note, for very large PDF's you may want to set "linearize" to false.

        <pdfDoc.SaveOptions.Linearize = false;>

This optimizes the PDF for web streaming, so if you are streaming the PDF, then you might want to leave it as true, but I've found it drastically increases the memory used by ABCPDF during the save.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号