summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2025-01-22 14:58:13 +0900
committerMiklos Vajna <vmiklos@collabora.com>2025-02-05 13:14:31 +0100
commit19bcc67e3dc1b046f3e76d46966ef24240ab40d9 (patch)
treeeebd6a9dfcf1d75a4335a1708e168380ddf57c14
parentccaeb27fafbd7ab40a6b811202edd6a65da639fb (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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180875 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 6dffb86b6c19..851663a9e101 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5156,6 +5156,13 @@ bool PDFWriterImpl::emitCatalog()
aWriter.startObject(rAttachedFile.mnObjectId);
aWriter.startDict();
aWriter.write("/Type", "/Filespec");
+
+ // 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)
{
@@ -5195,6 +5202,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 [");