This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
Fix issue #4290 (--copies not working with --collate). #4301
Open
vevisystems
wants to merge
1
commit into
wkhtmltopdf:master
Choose a base branch
from
vevisystems:fix_copies_rebased
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not sure about this, what happens in the call from line 887? I don't want to cause one more breakage due to a code path not being considered.
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.
As far as I understand the code (I have looked at it for just a few hours so I might be wrong) the loop at printDocument() deletes the web_printer after each object is used. The call from 887 (at beginPrintObject) deletes the web_printer of previous object when the loop advances, and finally the call from line 1012 clears the web_printer of the last object.
The problem is that when the "copies" loop (at 995) advances to print the next page, web_printers were already deleted so the next copy has nothing to print, and thus --copies always produces a single copy.
My solutions was to defer the web_printer deletion until all pages were processed, but of course it might be not the best solution (I might even be completely wrong!).
Be free to reject the PR if you have doubts about its correctness, as I said I have only looked at the code for a few hours. In any case, we have this solution working on a system that produces more than 50.000 PDFs per day (could not wait for official release because of the importance of the --copies feature to us), and it is working ok so far.
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.
That's good to know. I'll review it in more detail this weekend and merge it 👍
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.
Sorry about the delay, I've been a bit busy but I'll look at it this week.