When printing respect the overprint preview settings

Mainly two cases here:
  1. printing on Windows or force rasterization enabled, this goes
     through rasterization anyway, so just pass on the information
     as a render hint;
  2. printing on Linux, this goes through poppler's PSConverter, then we
     pass on the information only if we know the output won't be a PDF
     (otherwise we assume the consumer of this PDF will know what to do
     of the overprint information).

The latter case depends on new API introduced in Poppler 23.09.
This commit is contained in:
Kevin Ottens 2023-08-30 15:45:23 +02:00 committed by Albert Astals Cid
parent 9501f86ddb
commit 351cdf2388

View file

@ -1400,6 +1400,8 @@ Okular::Document::PrintError PDFGenerator::print(QPrinter &printer)
scaleMode = pdfOptionsPage->scaleMode();
}
const auto overprintPreviewEnabled = PDFSettings::overprintPreviewEnabled();
#ifdef Q_OS_WIN
// Windows can only print by rasterization, because that is
// currently the only way Okular implements printing without using UNIX-specific
@ -1409,6 +1411,7 @@ Okular::Document::PrintError PDFGenerator::print(QPrinter &printer)
if (forceRasterize) {
pdfdoc->setRenderHint(Poppler::Document::HideAnnotations, !printAnnots);
pdfdoc->setRenderHint(Poppler::Document::OverprintPreview, overprintPreviewEnabled);
if (pdfOptionsPage) {
// If requested, scale to full page instead of the printable area
@ -1509,6 +1512,11 @@ Okular::Document::PrintError PDFGenerator::print(QPrinter &printer)
psConverter->setForceRasterize(forceRasterize);
psConverter->setTitle(pstitle);
#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(23, 9, 0)
const auto isPdfOutput = printer.outputFormat() == QPrinter::PdfFormat;
psConverter->setForceOverprintPreview(!isPdfOutput && overprintPreviewEnabled);
#endif
if (!printAnnots) {
psConverter->setPSOptions(psConverter->psOptions() | Poppler::PSConverter::HideAnnotations);
}