Minor bugfixes

This commit is contained in:
Jakub Melka
2019-07-24 19:15:03 +02:00
parent 9a17daa5ab
commit ed15e37a52
3 changed files with 61 additions and 8 deletions

View File

@ -50,10 +50,48 @@ QList<PDFRenderError> PDFRenderer::render(QPainter* painter, const QRectF& recta
Q_ASSERT(page);
QRectF mediaBox = page->getMediaBox();
const PageRotation rotation = page->getPageRotation();
mediaBox = page->getRotatedBox(mediaBox, rotation);
QMatrix matrix;
matrix.translate(rectangle.left(), rectangle.bottom());
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
switch (rotation)
{
case PageRotation::None:
{
matrix.translate(rectangle.left(), rectangle.bottom());
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
break;
}
case PageRotation::Rotate90:
{
matrix.translate(rectangle.left(), rectangle.top());
matrix.rotate(90);
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
break;
}
case PageRotation::Rotate270:
{
matrix.translate(rectangle.right(), rectangle.top());
matrix.rotate(-90);
matrix.scale(rectangle.width() / mediaBox.width(), -rectangle.height() / mediaBox.height());
break;
}
case PageRotation::Rotate180:
{
matrix.translate(rectangle.left(), rectangle.top());
matrix.scale(rectangle.width() / mediaBox.width(), rectangle.height() / mediaBox.height());
break;
}
default:
{
Q_ASSERT(false);
break;
}
}
PDFPainter processor(painter, m_features, matrix, page, m_document, m_fontCache, m_optionalContentActivity);
return processor.processContents();