Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 5a716e06 authored by Oliver Sander's avatar Oliver Sander

Implement rasterized printing with QPrinter with hidden annotations

Previously, rasterized printing would use the QPrinter backend whenever
annotations were to be printed, and fall back to the convert-to-ps
toolchain otherwise.  Effectively, this meant that printing on
windows without showing the annotations was not possible (because
on windows only the QPrinter can be used for printing).

Starting with poppler 0.60, there is a way to disable annotation
rendering for the renderToImage and renderToPainter methods that
are used by QPrinter.  This patch makes use of this new option,
making printing on windows without annotations possible.

Differential Revision:
parent a53a2402
......@@ -41,6 +41,15 @@ int main()
#include <poppler-qt5.h>
int main()
Poppler::Document::RenderHint hint = Poppler::Document::HideAnnotations;
return 0;
......@@ -15,3 +15,6 @@
/* Defined if we have the 0.53 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_53 1
/* Defined if we have the 0.60 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_60 1
......@@ -85,7 +85,7 @@ class PDFOptionsPage : public QWidget
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined HAVE_POPPLER_0_60
m_printAnnots->setVisible( false );
setPrintAnnots( true ); // Default value
......@@ -1076,15 +1076,24 @@ bool PDFGenerator::print( QPrinter& printer )
#ifdef Q_OS_WIN
// Windows can only print by rasterization and with annotations, because that is
// Windows can only print by rasterization, because that is
// currently the only way Okular implements printing without using UNIX-specific
// tools like 'lpr'.
forceRasterize = true;
#ifndef HAVE_POPPLER_0_60
// The Document::HideAnnotations flags was introduced in poppler 0.60
printAnnots = true;
#ifdef HAVE_POPPLER_0_60
if ( forceRasterize )
pdfdoc->setRenderHint(Poppler::Document::HideAnnotations, !printAnnots);
if ( forceRasterize && printAnnots)
QPainter painter;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment