[poppler] utils/pdftocairo.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Mar 12 23:10:08 UTC 2023


 utils/pdftocairo.cc |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit c630bb95af5790d8d438d7e3b1dae8bf9e4a1541
Author: Anton Thomasson <antonthomasson at gmail.com>
Date:   Sun Mar 12 10:10:03 2023 +0100

    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.

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);


More information about the poppler mailing list