PDF: write a TrimBox
This is necessary for PDF/X-4 conformance (§ 6.12), but does not hurt specify it always, matching the MediaBox. This work has been kindly sponsored by the QGIS project (https://qgis.org/). Change-Id: Ifc698f271eb1217da15413e4bf25321dea2e955f Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com> Reviewed-by: Albert Astals Cid <aacid@kde.org>bb10
parent
67dffd871f
commit
a3a91c947c
|
|
@ -2126,17 +2126,24 @@ void QPdfEnginePrivate::writePage()
|
||||||
qreal userUnit = calcUserUnit();
|
qreal userUnit = calcUserUnit();
|
||||||
|
|
||||||
addXrefEntry(pages.constLast());
|
addXrefEntry(pages.constLast());
|
||||||
|
|
||||||
|
// make sure we use the pagesize from when we started the page, since the user may have changed it
|
||||||
|
const QByteArray formattedPageWidth = QByteArray::number(currentPage->pageSize.width() / userUnit, 'f');
|
||||||
|
const QByteArray formattedPageHeight = QByteArray::number(currentPage->pageSize.height() / userUnit, 'f');
|
||||||
|
|
||||||
xprintf("<<\n"
|
xprintf("<<\n"
|
||||||
"/Type /Page\n"
|
"/Type /Page\n"
|
||||||
"/Parent %d 0 R\n"
|
"/Parent %d 0 R\n"
|
||||||
"/Contents %d 0 R\n"
|
"/Contents %d 0 R\n"
|
||||||
"/Resources %d 0 R\n"
|
"/Resources %d 0 R\n"
|
||||||
"/Annots %d 0 R\n"
|
"/Annots %d 0 R\n"
|
||||||
"/MediaBox [0 0 %s %s]\n",
|
"/MediaBox [0 0 %s %s]\n"
|
||||||
|
"/TrimBox [0 0 %s %s]\n",
|
||||||
pageRoot, pageStream, resources, annots,
|
pageRoot, pageStream, resources, annots,
|
||||||
// make sure we use the pagesize from when we started the page, since the user may have changed it
|
formattedPageWidth.constData(),
|
||||||
QByteArray::number(currentPage->pageSize.width() / userUnit, 'f').constData(),
|
formattedPageHeight.constData(),
|
||||||
QByteArray::number(currentPage->pageSize.height() / userUnit, 'f').constData());
|
formattedPageWidth.constData(),
|
||||||
|
formattedPageHeight.constData());
|
||||||
|
|
||||||
if (pdfVersion >= QPdfEngine::Version_1_6)
|
if (pdfVersion >= QPdfEngine::Version_1_6)
|
||||||
xprintf("/UserUnit %s\n", QByteArray::number(userUnit, 'f').constData());
|
xprintf("/UserUnit %s\n", QByteArray::number(userUnit, 'f').constData());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue