Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community 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: https://phabricator.kde.org/D7688
parent a53a2402
......@@ -41,6 +41,15 @@ int main()
}
" HAVE_POPPLER_0_53)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::Document::RenderHint hint = Poppler::Document::HideAnnotations;
return 0;
}
" HAVE_POPPLER_0_60)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h
......
......@@ -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
layout->addWidget(m_forceRaster);
layout->addStretch(1);
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined HAVE_POPPLER_0_60
m_printAnnots->setVisible( false );
#endif
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;
#endif
#endif
#ifdef HAVE_POPPLER_0_60
if ( forceRasterize )
{
pdfdoc->setRenderHint(Poppler::Document::HideAnnotations, !printAnnots);
#else
if ( forceRasterize && printAnnots)
{
#endif
QPainter painter;
painter.begin(&printer);
......
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