From f45401ce130f1377163e977f52b037b7b46b4910 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Fri, 13 Dec 2024 00:09:48 +0900 Subject: pdf: Don't write non-standard LO keys when using PDF/A or PDF/UA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178770 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl --- vcl/source/gdi/pdfwriter_impl.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index ec3d5ca549b0..faf795fa60c7 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6232,14 +6232,21 @@ bool PDFWriterImpl::emitTrailer() aLine.append( "> ]\n" ); } - 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( "\n" ); } - 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) -- cgit