Core: Introduce PDF Import-Export dialog (#20860)
* Core: Introduce PDF Import-Export dialog Currently, we only have hardcoded exporting to one pdf version, which leads to (as in one of the below issues) to problems, such as non-transparent layers, which are by default not supported in PDF/A-1b. So, this patch adds an option to the user to select their preferred PDF version by introducing new dialog under Import-Export in Preferences, and allowing to update that version before exporting. * Core: Add informational messages regarding selected PDF format * Gui: Handle Qt < 6.8 unsupported PDF format * Gui: Switch PDF export prefs dialog to use tr() * Gui: Remove center alignment of PDF version description --------- Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/PreferencePages/DlgSettingsPDF.h>
|
||||
|
||||
#include <Mod/Spreadsheet/App/Sheet.h>
|
||||
#include <Mod/Spreadsheet/App/SheetPy.h>
|
||||
@@ -302,9 +303,10 @@ void SheetView::printPdf()
|
||||
QStringLiteral("%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:
|
||||
// setPdfVersion sets the printed PDF Version to what is chosen in
|
||||
// Preferences/Import-Export/PDF more details under:
|
||||
// https://www.kdab.com/creating-pdfa-documents-qt/
|
||||
printer.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b);
|
||||
printer.setPdfVersion(Gui::Dialog::DlgSettingsPDF::evaluatePDFVersion());
|
||||
printer.setPageOrientation(QPageLayout::Landscape);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setOutputFileName(filename);
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/PreferencePages/DlgSettingsPDF.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawPagePy.h>
|
||||
@@ -183,9 +184,9 @@ void PagePrinter::printAllPdf(QPrinter* printer, App::Document* doc)
|
||||
QString documentName = QString::fromUtf8(doc->getName());
|
||||
QPdfWriter pdfWriter(outputFile);
|
||||
|
||||
// set the printed PDF Version to comply with PDF/A-1b, more details under:
|
||||
// https://www.kdab.com/creating-pdfa-documents-qt/
|
||||
pdfWriter.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b);
|
||||
// setPdfVersion sets the printed PDF Version to what is chosen in Preferences/Import-Export/PDF
|
||||
// more details under: https://www.kdab.com/creating-pdfa-documents-qt/
|
||||
pdfWriter.setPdfVersion(Gui::Dialog::DlgSettingsPDF::evaluatePDFVersion());
|
||||
|
||||
pdfWriter.setTitle(documentName);
|
||||
pdfWriter.setCreator(QString::fromStdString(App::Application::getNameWithVersion())
|
||||
@@ -352,7 +353,7 @@ void PagePrinter::printPdf(ViewProviderPage* vpPage, const std::string& file)
|
||||
// set up the pdfwriter
|
||||
QString outputFile = QString::fromStdString(filespec);
|
||||
QPdfWriter pdfWriter(outputFile);
|
||||
pdfWriter.setPdfVersion(QPagedPaintDevice::PdfVersion_A1b);
|
||||
pdfWriter.setPdfVersion(Gui::Dialog::DlgSettingsPDF::evaluatePDFVersion());
|
||||
QPageLayout pageLayout = pdfWriter.pageLayout();
|
||||
auto marginsdb = pageLayout.margins(QPageLayout::Millimeter);
|
||||
QString documentName = QString::fromUtf8(vpPage->getDrawPage()->getNameInDocument());
|
||||
|
||||
Reference in New Issue
Block a user