vcl/source/gdi/pdfwriter_impl.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
New commits: commit 31b601d8fc2afa73fb0afd9c1d58ad488aa038cf Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jan 22 14:58:13 2025 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Jan 22 15:32:45 2025 +0100 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 <qui...@gmail.com> Tested-by: Jenkins 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 [");