summaryrefslogtreecommitdiffstats
path: root/src/core/printing/pdfium_document_wrapper_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/printing/pdfium_document_wrapper_qt.cpp')
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/core/printing/pdfium_document_wrapper_qt.cpp b/src/core/printing/pdfium_document_wrapper_qt.cpp
index 1be27f1c6..6f415b50b 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.cpp
+++ b/src/core/printing/pdfium_document_wrapper_qt.cpp
@@ -50,11 +50,11 @@ int PdfiumDocumentWrapperQt::m_libraryUsers = 0;
class PdfiumPageWrapperQt {
public:
- PdfiumPageWrapperQt(FPDF_DOCUMENT data, int pageIndex, int targetWidth, int targetHeight)
+ PdfiumPageWrapperQt(FPDF_DOCUMENT data, int pageIndex)
: m_pageData(FPDF_LoadPage(data, pageIndex))
, m_width(FPDF_GetPageWidth(m_pageData))
, m_height(FPDF_GetPageHeight(m_pageData))
- , m_image(createImage(targetWidth, targetHeight))
+ , m_image(createImage())
{
}
@@ -77,16 +77,11 @@ public:
}
private:
- QImage createImage(int targetWidth, int targetHeight)
+ QImage createImage()
{
Q_ASSERT(m_pageData);
- if (targetWidth <= 0)
- targetWidth = m_width;
- if (targetHeight <= 0)
- targetHeight = m_height;
-
- QImage image(targetWidth, targetHeight, QImage::Format_ARGB32);
+ QImage image(m_width * 2, m_height * 2, QImage::Format_ARGB32);
Q_ASSERT(!image.isNull());
image.fill(0xFFFFFFFF);
@@ -112,9 +107,7 @@ private:
PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t size,
- const QSize& imageSize,
const char *password)
- : m_imageSize(imageSize * 2.0)
{
Q_ASSERT(pdfData);
Q_ASSERT(size);
@@ -137,11 +130,17 @@ QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t index)
return QImage();
}
- PdfiumPageWrapperQt pageWrapper((FPDF_DOCUMENT)m_documentHandle, index,
- m_imageSize.width(), m_imageSize.height());
+ PdfiumPageWrapperQt pageWrapper((FPDF_DOCUMENT)m_documentHandle, index);
return pageWrapper.image();
}
+bool PdfiumDocumentWrapperQt::pageIsLandscape(size_t index)
+{
+ double width = 0, height = 0;
+ FPDF_GetPageSizeByIndex((FPDF_DOCUMENT)m_documentHandle, index, &width, &height);
+ return (width > height);
+}
+
PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt()
{
FPDF_CloseDocument((FPDF_DOCUMENT)m_documentHandle);