add a setting to enable/disable pdfMerger use

preferencesAboutTextFull
Clément Fauconnier 3 years ago
parent 41de5ae2f5
commit 0530ab151b
  1. 1
      resources/etc/OpenBoard.config
  2. 17
      src/adaptors/UBExportFullPDF.cpp
  3. 1
      src/core/UBSettings.cpp
  4. 1
      src/core/UBSettings.h

@ -129,6 +129,7 @@ ExportBackgroundColor=false
Margin=20 Margin=20
PageFormat=A4 PageFormat=A4
Resolution=300 Resolution=300
UsePDFMerger=true
ZoomBehavior=4 ZoomBehavior=4
[Podcast] [Podcast]

@ -82,6 +82,18 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, const QStr
if (!pDocumentProxy || filename.length() == 0 || pDocumentProxy->pageCount() == 0) if (!pDocumentProxy || filename.length() == 0 || pDocumentProxy->pageCount() == 0)
return; return;
/*
PDFMerger is supposed to be working only for PDFs using 1.0 to 1.4 standard, but I encountered no issue using 1.7 documents.
Just tested with a few documents though so it could be a total mess to restore it without any possibility to disable it if an issue is encountered
A new setting is introduced to handle that possibility.
Also, calling simpleExporter here instead of the following code was done because I (wrongly) assumed that both codes was doing nearly the same thing, as I never
tested to remove the part of pdf-merger throwing an exception if pdf version is > 1.4 and that calling the following lines without modifying the version check
throws an exception and finally calls simpleExporter->persistsDocument
calling simpleExporter directly also resulted in fixing two issues where pdf overlay could be badly scaled (not matching with scale of annotations)
*/
bool usePDFMerger = UBSettings::settings()->pdfUsePDFMerger->get().toBool();
if (usePDFMerger)
{
//PDF //PDF
qDebug() << "exporting document to PDF Merger" << filename; qDebug() << "exporting document to PDF Merger" << filename;
QPrinter pdfPrinter; QPrinter pdfPrinter;
@ -143,6 +155,11 @@ void UBExportFullPDF::saveOverlayPdf(UBDocumentProxy* pDocumentProxy, const QStr
} }
if (pdfPainter) delete pdfPainter; if (pdfPainter) delete pdfPainter;
}
else
{
mSimpleExporter->persistsDocument(pDocumentProxy, filename);
}
} }

@ -405,6 +405,7 @@ void UBSettings::init()
pdfMargin = new UBSetting(this, "PDF", "Margin", "20"); pdfMargin = new UBSetting(this, "PDF", "Margin", "20");
pdfPageFormat = new UBSetting(this, "PDF", "PageFormat", "A4"); pdfPageFormat = new UBSetting(this, "PDF", "PageFormat", "A4");
pdfUsePDFMerger = new UBSetting(this, "PDF", "UsePDFMerger", "true");
pdfResolution = new UBSetting(this, "PDF", "Resolution", "300"); pdfResolution = new UBSetting(this, "PDF", "Resolution", "300");
pdfZoomBehavior = new UBSetting(this, "PDF", "ZoomBehavior", "4"); pdfZoomBehavior = new UBSetting(this, "PDF", "ZoomBehavior", "4");

@ -357,6 +357,7 @@ class UBSettings : public QObject
UBSetting* svgViewBoxMargin; UBSetting* svgViewBoxMargin;
UBSetting* pdfMargin; UBSetting* pdfMargin;
UBSetting* pdfPageFormat; UBSetting* pdfPageFormat;
UBSetting* pdfUsePDFMerger;
UBSetting* pdfResolution; UBSetting* pdfResolution;
UBSetting* pdfZoomBehavior; UBSetting* pdfZoomBehavior;

Loading…
Cancel
Save