diff options
author | Anton Thomasson <antonthomasson@gmail.com> | 2023-03-12 10:10:03 +0100 |
---|---|---|
committer | Anton Thomasson <antonthomasson@gmail.com> | 2023-03-12 10:50:10 +0100 |
commit | c630bb95af5790d8d438d7e3b1dae8bf9e4a1541 (patch) | |
tree | 07ec4b448d138ead54e4cdc6925069650a2608ca | |
parent | 90da1d7b9ee200a0006bd9a103a3da10e2022e3b (diff) |
pdftocairo: Don't do things based on first page
Remember document initialization status instead.
This prevents a segfault where even/odd rendering forgets to run
beginDocument as the "first" page is not to be rendered.
-rw-r--r-- | utils/pdftocairo.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc index 8a5f08fd..7d9a1954 100644 --- a/utils/pdftocairo.cc +++ b/utils/pdftocairo.cc @@ -906,6 +906,7 @@ int main(int argc, char *argv[]) int pg, pg_num_len; double pg_w, pg_h, tmp, output_w, output_h; int num_outputs; + bool documentInitialized = false; // parse args Win32Console win32Console(&argc, &argv); @@ -1195,7 +1196,7 @@ int main(int argc, char *argv[]) pg_h = doc->getPageMediaHeight(pg); } - if (printing && pg == firstPage) { + if (printing && !documentInitialized) { if (paperWidth < 0 || paperHeight < 0) { paperWidth = (int)ceil(pg_w); paperHeight = (int)ceil(pg_h); @@ -1233,8 +1234,9 @@ int main(int argc, char *argv[]) } getOutputSize(pg_w, pg_h, &output_w, &output_h); - if (pg == firstPage) { + if (!documentInitialized) { beginDocument(fileName, outputFileName, output_w, output_h); + documentInitialized = true; } beginPage(&output_w, &output_h); renderPage(doc.get(), cairoOut, pg, pg_w, pg_h, output_w, output_h); |