[poppler] qt5/src

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Sep 4 19:50:42 UTC 2017


 qt5/src/poppler-page.cc |   36 ++++++++++++++++++++++++++++++++++--
 qt5/src/poppler-qt5.h   |    3 ++-
 2 files changed, 36 insertions(+), 3 deletions(-)

New commits:
commit 340a99f580b9f7b6add831e9a0252574bfea66f2
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date:   Fri Sep 1 22:16:49 2017 +0200

    Control whether renderToImage shows annotations
    
    I'd like to control whether the renderToImage and renderToPainter
    methods show annotations or not. To this end, this patch introduces
    a new value 'HideAnnotations' to the Document::RenderHint enum.

diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc
index 0d2dd5a8..3ff676ec 100644
--- a/qt5/src/poppler-page.cc
+++ b/qt5/src/poppler-page.cc
@@ -365,9 +365,24 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
 
       splash_output.startDoc(m_page->parentDoc->doc);
 
+      const GBool hideAnnotations = m_page->parentDoc->m_hints & Document::HideAnnotations;
+
+      // Callback that filters out everything but form fields
+      auto annotDisplayDecideCbk = [](Annot *annot, void *user_data)
+      {
+        // Hide everything but forms
+        return (annot->getType() == Annot::typeWidget);
+      };
+
+      // A nullptr, but with the type of a function pointer
+      // Needed to make the ternary operator below happy.
+      GBool (*nullCallBack)(Annot *annot, void *user_data) = nullptr;
+
       m_page->parentDoc->doc->displayPageSlice(&splash_output, m_page->index + 1, xres, yres,
                                                rotation, false, true, false, x, y, w, h,
-                                               NULL, NULL, NULL, NULL, gTrue);
+                                               nullptr, nullptr,
+                                               (hideAnnotations) ? annotDisplayDecideCbk : nullCallBack,
+                                               nullptr, gTrue);
 
       SplashBitmap *bitmap = splash_output.getBitmap();
 
@@ -450,6 +465,20 @@ bool Page::renderToPainter(QPainter* painter, double xres, double yres, int x, i
       painter->translate(x == -1 ? 0 : -x, y == -1 ? 0 : -y);
       ArthurOutputDev arthur_output(painter);
       arthur_output.startDoc(m_page->parentDoc->doc->getXRef());
+
+      const GBool hideAnnotations = m_page->parentDoc->m_hints & Document::HideAnnotations;
+
+      // Callback that filters out everything but form fields
+      auto annotDisplayDecideCbk = [](Annot *annot, void *user_data)
+      {
+        // Hide everything but forms
+        return (annot->getType() == Annot::typeWidget);
+      };
+
+      // A nullptr, but with the type of a function pointer
+      // Needed to make the ternary operator below happy.
+      GBool (*nullCallBack)(Annot *annot, void *user_data) = nullptr;
+
       m_page->parentDoc->doc->displayPageSlice(&arthur_output,
                                                m_page->index + 1,
                                                xres,
@@ -461,7 +490,10 @@ bool Page::renderToPainter(QPainter* painter, double xres, double yres, int x, i
                                                x,
                                                y,
                                                w,
-                                               h);
+                                               h,
+                                               nullptr,
+                                               nullptr,
+                                               (hideAnnotations) ? annotDisplayDecideCbk : nullCallBack);
       if (savePainter)
          painter->restore();
       return true;
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index e44e22d4..58a7925a 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -893,7 +893,8 @@ delete it;
 	    OverprintPreview = 0x00000010,  ///< Overprint preview \since 0.22
 	    ThinLineSolid = 0x00000020,     ///< Enhance thin lines solid \since 0.24
 	    ThinLineShape = 0x00000040,     ///< Enhance thin lines shape. Wins over ThinLineSolid \since 0.24
-	    IgnorePaperColor = 0x00000080   ///< Do not compose with the paper color \since 0.35
+	    IgnorePaperColor = 0x00000080,  ///< Do not compose with the paper color \since 0.35
+	    HideAnnotations = 0x00000100    ///< Do not render annotations \since 0.60
 	};
 	Q_DECLARE_FLAGS( RenderHints, RenderHint )
 


More information about the poppler mailing list