You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
1.1 KiB

#include "PdfExportJob.h"
#include "control/Control.h"
#include "pdf/base/XojPdfExport.h"
#include "pdf/base/XojPdfExportFactory.h"
#include "i18n.h"
PdfExportJob::PdfExportJob(Control* control): BaseExportJob(control, _("PDF Export")) {}
PdfExportJob::~PdfExportJob() = default;
void PdfExportJob::addFilterToDialog() { addFileFilterToDialog(_("PDF files"), "*.pdf"); }
auto PdfExportJob::testAndSetFilepath(fs::path file) -> bool {
if (!BaseExportJob::testAndSetFilepath(std::move(file))) {
return false;
}
// Remove any pre-existing extension and adds .pdf
Util::clearExtensions(filepath, ".pdf");
filepath += ".pdf";
return checkOverwriteBackgroundPDF(filepath);
}
void PdfExportJob::run() {
Document* doc = control->getDocument();
doc->lock();
XojPdfExport* pdfe = XojPdfExportFactory::createExport(doc, control);
doc->unlock();
if (!pdfe->createPdf(this->filepath)) {
if (control->getWindow()) {
callAfterRun();
} else {
this->errorMsg = pdfe->getLastError();
}
}
delete pdfe;
}