vcl/source/gdi/pdfwriter_impl.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 16ef71ab4f3c8fcc2d50ee3f9097820af77765c3
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Dec 13 00:09:48 2024 +0900
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Dec 16 14:00:14 2024 +0100

    pdf: Don't write non-standard LO keys when using PDF/A or PDF/UA
    
    We write /DocChecksum and /AdditionalStreams entries into the
    trailer dictionary, which is not allowed by the standard in any
    case. To avoid a potential compliance checker to report errors
    because of this, the writing is shorted out if PDF/A or PDF/UA
    are enabled.
    
    Change-Id: I98247e89f1984f158ffbcb78b9e3713fcab053fe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178414
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 42bbe5c22bfa..f94e093a1492 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6176,14 +6176,21 @@ bool PDFWriterImpl::emitTrailer()
         aLine.append( "> ]
" );
     }
 
-    if( !aDocChecksum.isEmpty() )
+    // Writes the /DocChecksum - hash off the PDF stream
+    // This entry is not defined in the standard, so don't write it if we
+    // are using PDF/UA or PDF/A as the compliance checkers will complain.
+    // Actually we shouldn't write it at all...
+    if (!aDocChecksum.isEmpty() && !m_bIsPDF_UA && m_nPDFA_Version == 0)
     {
         aLine.append( "/DocChecksum /" );
         aLine.append( aDocChecksum );
         aLine.append( "
" );
     }
 
-    if (!m_aDocumentAttachedFiles.empty())
+    // Writes the /AdditionalStreams - writes the embedded / attached files 
into the PDF
+    // This entry is not defined in the standard, so don't write it if we
+    // are using PDF/UA or PDF/A as the compliance checkers will complain.
+    if (!m_aDocumentAttachedFiles.empty() && !m_bIsPDF_UA && m_nPDFA_Version 
== 0)
     {
         aLine.append( "/AdditionalStreams [" );
         for (auto const& rAttachedFile : m_aDocumentAttachedFiles)

Reply via email to