diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2025-01-22 14:58:13 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2025-01-22 15:32:45 +0100 |
commit | 31b601d8fc2afa73fb0afd9c1d58ad488aa038cf (patch) | |
tree | 699fb2e6682bd25cc597aff24b86fc8c5203b08d | |
parent | 001397c7463f7591811beeb9d03f637f2447ed3f (diff) |
tdf#160196 add /AF entry to catalog, enable assoc. files in PDF/A-3
PDF 2.0 introduced "associated files" entry. Add the association
for the attached files to the /Catalog (/AF entry) and make sure
the /AFRelationship is set to /Source.
Also enable this for PDF/A-3 (where this was apparently added),
as this is required.
Change-Id: I5d0048daeb6e78534cef8ceb467f6dd2627a53ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180566
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Jenkins
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 5945e43f0460..a284cbbcb541 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5259,10 +5259,13 @@ bool PDFWriterImpl::emitCatalog() aWriter.startObject(rAttachedFile.mnObjectId); aWriter.startDict(); aWriter.write("/Type", "/Filespec"); - if (PDFWriter::PDFVersion::PDF_2_0 <= m_aContext.Version) + + // Add associated files relationship (since PDF 2.0) + if (m_aContext.Version >= PDFWriter::PDFVersion::PDF_2_0 || m_nPDFA_Version == 3) { aWriter.write("/AFRelationship", "/Source"); } + aWriter.writeKeyAndUnicodeEncrypt("/F", rAttachedFile.maFilename, rAttachedFile.mnObjectId); if (PDFWriter::PDFVersion::PDF_1_7 <= m_aContext.Version) { @@ -5302,6 +5305,16 @@ bool PDFWriterImpl::emitCatalog() if (!m_aDocumentAttachedFiles.empty()) { + // Write the associated files catalog entry (since PDF 2.0) + if (m_aContext.Version >= PDFWriter::PDFVersion::PDF_2_0 || m_nPDFA_Version == 3) + { + aLine.append("/AF"); + aLine.append("["); + for (auto & rAttachedFile : m_aDocumentAttachedFiles) + aWriter.writeReference(rAttachedFile.mnObjectId); + aLine.append("]"); + } + aWriter.startDictWithKey("/Names"); aWriter.startDictWithKey("/EmbeddedFiles"); aLine.append("/Names ["); |