Editor plugin: SVG images

This commit is contained in:
Jakub Melka
2024-06-16 18:32:38 +02:00
parent 758e5fe7bb
commit c52e487b04
5 changed files with 268 additions and 0 deletions

View File

@ -210,6 +210,9 @@ bool EditorPlugin::save()
const pdf::PDFPage* page = m_document->getCatalog()->getPage(pageIndex);
const pdf::PDFEditedPageContent& editedPageContent = m_editedPageContent.at(pageIndex);
QRectF mediaBox = page->getMediaBox();
QRectF mediaBoxMM = page->getMediaBoxMM();
pdf::PDFPageContentEditorContentStreamBuilder contentStreamBuilder(m_document);
contentStreamBuilder.setFontDictionary(editedPageContent.getFontDictionary());
@ -290,8 +293,24 @@ bool EditorPlugin::save()
else
{
// It is probably an SVG image
pdf::PDFContentEditorPaintDevice paintDevice(&contentStreamBuilder, mediaBox, mediaBoxMM);
QPainter painter(&paintDevice);
QList<pdf::PDFRenderError> errors;
pdf::PDFTextLayoutGetter textLayoutGetter(nullptr, pageIndex);
elementImage->drawPage(&painter, &m_scene, pageIndex, nullptr, textLayoutGetter, QTransform(), errors);
}
}
if (elementTextBox)
{
pdf::PDFContentEditorPaintDevice paintDevice(&contentStreamBuilder, mediaBox, mediaBoxMM);
QPainter painter(&paintDevice);
QList<pdf::PDFRenderError> errors;
pdf::PDFTextLayoutGetter textLayoutGetter(nullptr, pageIndex);
elementTextBox->drawPage(&painter, &m_scene, pageIndex, nullptr, textLayoutGetter, QTransform(), errors);
}
}
}