From 4f5cf9d1a5511e07c63fecc358c85743b81c3f59 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Thu, 21 Apr 2016 16:08:24 +0200 Subject: [PATCH] When exporting to PDF merger, make sure to scale PDF items on the page if necessary --- src/adaptors/UBExportFullPDF.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/adaptors/UBExportFullPDF.cpp b/src/adaptors/UBExportFullPDF.cpp index db11ea5c..d370e548 100644 --- a/src/adaptors/UBExportFullPDF.cpp +++ b/src/adaptors/UBExportFullPDF.cpp @@ -62,7 +62,7 @@ UBExportFullPDF::UBExportFullPDF(QObject *parent) //need to calculate screen resolution QDesktopWidget* desktop = UBApplication::desktop(); int dpiCommon = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; - mScaleFactor = 72.0f / dpiCommon; + mScaleFactor = 72.0f / dpiCommon; // 1pt = 1/72 inch mSimpleExporter = new UBExportPDF(); } @@ -206,7 +206,12 @@ bool UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS xPdfOffset += (xPdf - xAnnotation) * scaleFactor * mScaleFactor; yPdfOffset -= (yPdf - yAnnotation) * scaleFactor * mScaleFactor; - TransformationDescription pdfTransform(xPdfOffset, yPdfOffset, scaleFactor, 0); + // If the PDF was scaled when added to the scene (e.g if it was loaded from a document with a different DPI + // than the current one), it should also be scaled here. + qreal currentDpi = (UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY()) / 2; + qreal pdfScale = qreal(UBSettings::pageDpi)/currentDpi; + + TransformationDescription pdfTransform(xPdfOffset, yPdfOffset, scaleFactor * pdfScale, 0); TransformationDescription annotationTransform(xAnnotationsOffset, yAnnotationsOffset, 1, 0); MergePageDescription pageDescription(pageSize.width() * mScaleFactor,