Improve PDF/A-1b support in QPdfWriter

Fix warning of missing F key in Annot directory. The F key needs
to have the printing flag (bit 3) enabled and all other bits disabled.
(Clause 6.5.3 in ISO 19005-1:2005)

Change-Id: Iddba6b71f516aca75cd573584aa184c1b808863d
Reviewed-by: André Klitzing <aklitzing@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Tobias Koenig 2017-09-14 10:14:48 +02:00
parent 306a6b9dec
commit 62ea3eaf05

View File

@ -1063,7 +1063,12 @@ void QPdfEngine::drawHyperlink(const QRectF &r, const QUrl &url)
char buf[256];
const QRectF rr = d->pageMatrix().mapRect(r);
d->xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect [");
d->xprintf("<<\n/Type /Annot\n/Subtype /Link\n");
if (d->pdfVersion == QPdfEngine::Version_A1b)
d->xprintf("/F 4\n"); // enable print flag, disable all other
d->xprintf("/Rect [");
d->xprintf("%s ", qt_real_to_string(rr.left(), buf));
d->xprintf("%s ", qt_real_to_string(rr.top(), buf));
d->xprintf("%s ", qt_real_to_string(rr.right(), buf));
@ -2831,7 +2836,12 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
x2s.setNum(static_cast<double>(x2), 'f');
y2s.setNum(static_cast<double>(y2), 'f');
QByteArray rectData = x1s + ' ' + y1s + ' ' + x2s + ' ' + y2s;
xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect [");
xprintf("<<\n/Type /Annot\n/Subtype /Link\n");
if (pdfVersion == QPdfEngine::Version_A1b)
xprintf("/F 4\n"); // enable print flag, disable all other
xprintf("/Rect [");
xprintf(rectData.constData());
#ifdef Q_DEBUG_PDF_LINKS
xprintf("]\n/Border [16 16 1]\n/A <<\n");