Bugfix: Draw form fields

This commit is contained in:
Jakub Melka 2024-06-27 18:31:45 +02:00
parent 8166d9f8f4
commit a4feda2d06
9 changed files with 18 additions and 7 deletions

View File

@ -1427,10 +1427,12 @@ void PDFAnnotationManager::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
Q_UNUSED(compiledPage);
Q_UNUSED(layoutGetter);
Q_UNUSED(convertor);
const PDFPage* page = m_document->getCatalog()->getPage(pageIndex);
Q_ASSERT(page);

View File

@ -1474,6 +1474,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const;
/// Set document

View File

@ -241,10 +241,13 @@ QImage PDFRasterizer::render(PDFInteger pageIndex,
QSize size,
PDFRenderer::Features features,
const PDFAnnotationManager* annotationManager,
const PDFCMS* cms,
PageRotation extraRotation)
{
QImage image(size, QImage::Format_ARGB32_Premultiplied);
PDFColorConvertor convertor = cms->getColorConvertor();
PDFRenderer::applyFeaturesToColorConvertor(features, convertor);
QTransform matrix = PDFRenderer::createPagePointToDevicePointMatrix(page, QRect(QPoint(0, 0), size), extraRotation);
if (m_rendererEngine == RendererEngine::Blend2D_MultiThread ||
@ -259,7 +262,7 @@ QImage PDFRasterizer::render(PDFInteger pageIndex,
{
QList<PDFRenderError> errors;
PDFTextLayoutGetter textLayoutGetter(nullptr, pageIndex);
annotationManager->drawPage(&painter, pageIndex, compiledPage, textLayoutGetter, matrix, errors);
annotationManager->drawPage(&painter, pageIndex, compiledPage, textLayoutGetter, matrix, convertor, errors);
}
}
else
@ -274,7 +277,7 @@ QImage PDFRasterizer::render(PDFInteger pageIndex,
{
QList<PDFRenderError> errors;
PDFTextLayoutGetter textLayoutGetter(nullptr, pageIndex);
annotationManager->drawPage(&painter, pageIndex, compiledPage, textLayoutGetter, matrix, errors);
annotationManager->drawPage(&painter, pageIndex, compiledPage, textLayoutGetter, matrix, convertor, errors);
}
}
@ -381,7 +384,7 @@ void PDFRasterizerPool::render(const std::vector<PDFInteger>& pageIndices,
pageTimer.restart();
PDFRasterizer* rasterizer = acquire();
qint64 pageWaitTime = pageTimer.restart();
QImage image = rasterizer->render(pageIndex, page, &precompiledPage, imageSizeGetter(page), m_features, &annotationManager, PageRotation::None);
QImage image = rasterizer->render(pageIndex, page, &precompiledPage, imageSizeGetter(page), m_features, &annotationManager, cms.data(), PageRotation::None);
qint64 pageRenderTime = pageTimer.elapsed();
release(rasterizer);

View File

@ -164,6 +164,7 @@ public:
/// \param size Size of the target image
/// \param features Renderer features
/// \param annotationManager Annotation manager (can be nullptr)
/// \param cms Color management system
/// \param extraRotation Extra page rotation
QImage render(PDFInteger pageIndex,
const PDFPage* page,
@ -171,6 +172,7 @@ public:
QSize size,
PDFRenderer::Features features,
const PDFAnnotationManager* annotationManager,
const PDFCMS* cms,
PageRotation extraRotation);
private:

View File

@ -958,7 +958,8 @@ QImage PDFDrawWidgetProxy::drawThumbnailImage(PDFInteger pageIndex, int pixelSiz
if (compiledPage && compiledPage->isValid())
{
// Rasterize the image.
image = m_rasterizer->render(pageIndex, page, compiledPage, imageSize, m_features, m_widget->getAnnotationManager(), PageRotation::None);
PDFCMSPointer cms = getCMSManager()->getCurrentCMS();
image = m_rasterizer->render(pageIndex, page, compiledPage, imageSize, m_features, m_widget->getAnnotationManager(), cms.data(), PageRotation::None);
}
if (image.isNull())

View File

@ -534,9 +534,10 @@ void PDFWidgetAnnotationManager::drawPage(QPainter* painter,
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const
{
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, errors);
BaseClass::drawPage(painter, pageIndex, compiledPage, layoutGetter, pagePointToDevicePointMatrix, convertor, errors);
}
} // namespace pdf

View File

@ -55,6 +55,7 @@ public:
const PDFPrecompiledPage* compiledPage,
PDFTextLayoutGetter& layoutGetter,
const QTransform& pagePointToDevicePointMatrix,
const PDFColorConvertor& convertor,
QList<PDFRenderError>& errors) const override;
/// Returns tooltip generated from annotation

View File

@ -701,7 +701,7 @@ void PDFWidgetFormManager::updateFormWidgetEditors()
setFocusToEditor(nullptr);
clearEditors();
for (PDFFormWidget widget : getWidgets())
for (const PDFFormWidget& widget : getWidgets())
{
const PDFFormField* formField = widget.getParent();
switch (formField->getFieldType())

View File

@ -191,7 +191,7 @@ QPixmap PageItemDelegate::getPageImagePixmap(const PageGroupItem* item, QRect re
renderer.compile(&compiledPage, pageIndex);
QSize imageSize = rect.size() * m_dpiScaleRatio;
QImage pageImage = m_rasterizer->render(pageIndex, page, &compiledPage, imageSize, pdf::PDFRenderer::getDefaultFeatures(), nullptr, groupItem.pageAdditionalRotation);
QImage pageImage = m_rasterizer->render(pageIndex, page, &compiledPage, imageSize, pdf::PDFRenderer::getDefaultFeatures(), nullptr, cms.data(), groupItem.pageAdditionalRotation);
pixmap = QPixmap::fromImage(qMove(pageImage));
}
}