7 #include "DlgImportCroppingPdf.h" 8 #include "ImportCroppingUtilPdf.h" 10 #include "poppler-qt5.h" 11 #include <QApplication> 17 const int X_TOP_LEFT = 0, Y_TOP_LEFT = 0;
18 const int WIDTH = -1, HEIGHT = -1;
19 const int FIRST_PAGE_1_BASED = 1;
28 ImportCropping importCropping,
29 bool isErrorReportRegressionTest)
const 40 QApplication::setOverrideCursor(Qt::BusyCursor);
43 rtn = loadWithCropping (document,
49 rtn = loadWithoutCropping (fileName,
54 QApplication::restoreOverrideCursor();
63 PdfReturn Pdf::loadWithCropping (
Document *document,
67 PdfReturn pdfReturn = PDF_RETURN_FAILED;
72 if (dlg.exec() == QDialog::Accepted) {
77 if (!image.isNull()) {
78 pdfReturn = PDF_RETURN_SUCCESS;
82 pdfReturn = PDF_RETURN_CANCELED;
88 PdfReturn Pdf::loadWithoutCropping (
const QString &fileName,
92 PdfReturn pdfReturn = PDF_RETURN_FAILED;
95 if (fileName.right (4).toLower () ==
".pdf") {
98 Document *document = Document::load (fileName);
101 if (!document->isLocked ()) {
103 Page *page = document->page (FIRST_PAGE_1_BASED - 1);
106 image = page->renderToImage (resolution,
113 if (!image.isNull()) {
114 pdfReturn = PDF_RETURN_SUCCESS;
QImage image() const
Image that was selected. Value is null if loading failed.
bool applyImportCropping(bool isRegression, const QString &fileName, ImportCropping importCropping, Poppler::Document *&document) const
For pdf files, skip cropping dialog during regression testing, otherwise crop if it is always turned ...
Storage of one imported image and the data attached to that image.
Dialog for selecting a page and frame on that page when importing an image from a pdf file...
PdfReturn load(const QString &fileName, QImage &image, int resolution, ImportCropping importCropping, bool isErrorReportRegressionTest) const
Try to load the specified file. Success is indicated in the function return value.