Issue #71: Pages are "mirrored"

This commit is contained in:
Jakub Melka 2023-07-27 12:46:44 +02:00
parent 1dcd6c3db1
commit 51181bd30b
3 changed files with 18 additions and 9 deletions

View File

@ -1205,10 +1205,10 @@ PDFAnnotationManager::~PDFAnnotationManager()
}
QTransform PDFAnnotationManager::prepareTransformations(const QTransform& pagePointToDevicePointMatrix,
QPaintDevice* device,
const PDFAnnotation::Flags annotationFlags,
const PDFPage* page,
QRectF& annotationRectangle) const
QPaintDevice* device,
const PDFAnnotation::Flags annotationFlags,
const PDFPage* page,
QRectF& annotationRectangle) const
{
// "Unrotate" user coordinate space, if NoRotate flag is set
QTransform userSpaceToDeviceSpace = pagePointToDevicePointMatrix;

View File

@ -709,10 +709,15 @@ QTransform PDFDrawWidgetProxy::createPagePointToDevicePointMatrix(const PDFPage*
case PageRotation::Rotate180:
{
matrix.translate(0, rectangle.top() + rectangle.bottom());
matrix.translate(rectangle.left(), rectangle.top() + rectangle.bottom());
matrix.scale(1.0, -1.0);
matrix.translate(rectangle.width(), 0);
matrix.scale(-1.0, 1.0);
matrix.translate(-rectangle.left(), 0);
Q_ASSERT(qFuzzyCompare(matrix.map(rectangle.topLeft()).y(), rectangle.bottom()));
Q_ASSERT(qFuzzyCompare(matrix.map(rectangle.bottomLeft()).y(), rectangle.top()));
Q_ASSERT(qFuzzyCompare(matrix.map(rectangle.topLeft()).x(), rectangle.right()));
Q_ASSERT(qFuzzyCompare(matrix.map(rectangle.bottomRight()).x(), rectangle.left()));
break;
}

View File

@ -52,8 +52,8 @@ PDFRenderer::PDFRenderer(const PDFDocument* document,
}
QTransform PDFRenderer::createPagePointToDevicePointMatrix(const PDFPage* page,
const QRectF& rectangle,
PageRotation extraRotation)
const QRectF& rectangle,
PageRotation extraRotation)
{
PageRotation pageRotation = getPageRotationCombined(page->getPageRotation(), extraRotation);
QRectF mediaBox = page->getRotatedBox(page->getMediaBox(), pageRotation);
@ -72,6 +72,7 @@ QTransform PDFRenderer::createMediaBoxToDevicePointMatrix(const QRectF& mediaBox
{
matrix.translate(rectangle.left(), rectangle.bottom());
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
matrix.translate(-mediaBox.left(), -mediaBox.top());
break;
}
@ -80,6 +81,7 @@ QTransform PDFRenderer::createMediaBoxToDevicePointMatrix(const QRectF& mediaBox
matrix.translate(rectangle.left(), rectangle.top());
matrix.rotate(90);
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
matrix.translate(-mediaBox.left(), -mediaBox.top());
break;
}
@ -89,6 +91,7 @@ QTransform PDFRenderer::createMediaBoxToDevicePointMatrix(const QRectF& mediaBox
matrix.rotate(-90);
matrix.translate(-rectangle.height(), 0);
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
matrix.translate(-mediaBox.left(), -mediaBox.top());
break;
}
@ -96,6 +99,9 @@ QTransform PDFRenderer::createMediaBoxToDevicePointMatrix(const QRectF& mediaBox
{
matrix.translate(rectangle.left(), rectangle.top());
matrix.scale(rectangle.width() / mediaBox.width(), rectangle.height() / mediaBox.height());
matrix.translate(mediaBox.width(), 0);
matrix.translate(-mediaBox.left(), -mediaBox.top());
matrix.scale(-1.0, 1.0);
break;
}
@ -106,8 +112,6 @@ QTransform PDFRenderer::createMediaBoxToDevicePointMatrix(const QRectF& mediaBox
}
}
matrix.translate(-mediaBox.left(), -mediaBox.top());
return matrix;
}