summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpdf_p.h
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2022-10-28 10:56:00 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2022-11-13 09:47:22 +0000
commit5d95205bae4e6b279d6eb99c3b5f81f95c9b031e (patch)
treef6caabc412c1e8ce926fc66aa653e406fb8c644a /src/gui/painting/qpdf_p.h
parenta9f94d078a94ca15adf4d8143cba52c4369d45d5 (diff)
PDF writer: implement support for document internal links
QPdfEngine already supported links to external URIs, but not internal links for navigation in a document. For internal links, PDF supports "named destinations" instead of direct coordinates. That way, we avoid the need for a two-pass implementation. Instead, we just store the name and position of all anchors as we enounter them. At document finishing time, we export the list of named destinations in a PDF "name tree" structure. The PDF named destinations feature uses the same main catalog item ("Names") as the attached files feature. Hence, this commit must slightly change the implementation of file attachment support also, so that the structure supports both. Now, we always add a reference to a Names object in the catalog when we start the document. When we finish, we write that object, making it reference the attached files-structure and/or the named destinations-structure, as needed. Fixes: QTBUG-83458 Change-Id: I9c43e7b423062d3f21965ab8a0d81a53c4dd72cb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/painting/qpdf_p.h')
-rw-r--r--src/gui/painting/qpdf_p.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index 4c6a570e76..2c70ddf664 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -271,7 +271,9 @@ private:
int writeXmpDcumentMetaData();
int writeOutputIntent();
void writePageRoot();
+ void writeDestsRoot();
void writeAttachmentRoot();
+ void writeNamesRoot();
void writeFonts();
void embedFont(QFontSubset *font);
qreal calcUserUnit() const;
@@ -305,11 +307,20 @@ private:
QString mimeType;
};
+ struct DestInfo
+ {
+ QString anchor;
+ uint pageObj;
+ QPointF coords;
+ };
+
// various PDF objects
- int pageRoot, embeddedfilesRoot, namesRoot, catalog, info, graphicsState, patternColorSpace;
+ int pageRoot, namesRoot, destsRoot, attachmentsRoot, catalog, info;
+ int graphicsState, patternColorSpace;
QList<uint> pages;
QHash<qint64, uint> imageCache;
QHash<QPair<uint, uint>, uint > alphaCache;
+ QList<DestInfo> destCache;
QList<AttachmentInfo> fileCache;
QByteArray xmpDocumentMetadata;
};