From 529f9401f7fc3f8b6cdae8ce9d9057b58dfb87ee Mon Sep 17 00:00:00 2001 From: Tobias Falk Date: Tue, 27 Jun 2023 22:57:26 +0200 Subject: [PATCH] added PDF/A-1b compliancy to all PDF export functions for more details about this look at: https://www.kdab.com/creating-pdfa-documents-qt/ --- src/Gui/ApplicationPy.cpp | 2 ++ src/Gui/EditorView.cpp | 2 ++ src/Gui/MDIView.cpp | 2 ++ src/Gui/View3DInventor.cpp | 2 ++ src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp | 2 ++ src/Mod/TechDraw/Gui/MDIViewPage.cpp | 4 ++++ 6 files changed, 14 insertions(+) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index d9a43af0bf..31a9420f5f 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -707,6 +707,8 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args) if (view3d) view3d->viewAll(); QPrinter printer(QPrinter::ScreenResolution); + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(fileName); view->print(&printer); diff --git a/src/Gui/EditorView.cpp b/src/Gui/EditorView.cpp index f56570ffc3..89db2b611a 100644 --- a/src/Gui/EditorView.cpp +++ b/src/Gui/EditorView.cpp @@ -471,6 +471,8 @@ void EditorView::printPdf() QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file"))); if (!filename.isEmpty()) { QPrinter printer(QPrinter::ScreenResolution); + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(filename); d->textEdit->document()->print(&printer); diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index e11870b44c..3227c82282 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -254,6 +254,8 @@ void MDIView::printPdf() QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file"))); if (!filename.isEmpty()) { QPrinter printer(QPrinter::ScreenResolution); + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(filename); print(&printer); diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 853ef180a4..d436c49c38 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -246,6 +246,8 @@ void View3DInventor::printPdf() if (!filename.isEmpty()) { Gui::WaitCursor wc; QPrinter printer(QPrinter::ScreenResolution); + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); printer.setOutputFormat(QPrinter::PdfFormat); printer.setPageOrientation(QPageLayout::Landscape); printer.setOutputFileName(filename); diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp index 3838b44521..e84c46a4f2 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp @@ -255,6 +255,8 @@ void SheetView::printPdf() QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file"))); if (!filename.isEmpty()) { QPrinter printer(QPrinter::ScreenResolution); + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); printer.setPageOrientation(QPageLayout::Landscape); printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(filename); diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index 6278a304ef..204fc3ac09 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -303,6 +303,8 @@ void MDIViewPage::printPdf(std::string file) QString filename = QString::fromUtf8(file.data(), file.size()); QPrinter printer(QPrinter::HighResolution); + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); printer.setFullPage(true); printer.setOutputFileName(filename); @@ -513,6 +515,8 @@ void MDIViewPage::printAll(QPrinter* printer, App::Document* doc) //static routine to print all pages in a document to pdf void MDIViewPage::printAllPdf(QPrinter* printer, App::Document* doc) { + // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ + printer->setPdfVersion(QPagedPaintDevice::PdfVersion_A1b); // Base::Console().Message("MDIVP::printAllPdf()\n"); QString outputFile = printer->outputFileName(); QString documentName = QString::fromUtf8(doc->getName());