-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor PDF exports for headless printing #891
base: master
Are you sure you want to change the base?
Refactor PDF exports for headless printing #891
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to print a test 200-page document I get to about 14% (very slowly) and it runs out of memory and barfs.
for (int i = 0; i < rs.getPageCount(); i++) { | ||
merger.addSource(rs.exportPDF(i, pageFormat)); | ||
} | ||
iter.remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sheet instances take up a lot more memory when processed, and large jobs can easily run out of memory. I tried clearing generated data from the PrintRecordSheet instance without success. The only way I found to handle the memory problems is to remove the sheets once they're added to the document. I don't see any reason the book needs to be reusable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll test this with a large document tonight, good to know that was the issue.
I found some other items that kept large amounts of memory rooted and will put up a separate PR.
This PR refactors PDF exports to more easily allow headless printing.
Here is an example of it in use from a web service: