vcl/inc/pdf/XmpMetadata.hxx | 10 +++++++--- vcl/source/gdi/pdfwriter_impl.cxx | 9 +++++++++ vcl/source/pdf/XmpMetadata.cxx | 22 +++++++++++++--------- 3 files changed, 29 insertions(+), 12 deletions(-)
New commits: commit b5385504c374a0b7a89e6e3a02f6f8957414ef75 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Dec 17 23:48:52 2024 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Dec 18 10:20:15 2024 +0100 pdf: write correct conformance XPM metadata for PDF/A-4 Also write pdfaid:rev when we write metadata for PDF/A-4 (revision 2020). Change-Id: Idb1864ca2b66aa43e8c2f118e945d5fb37932935 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178676 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx index 33fce97a21e3..452ad7f85267 100644 --- a/vcl/inc/pdf/XmpMetadata.hxx +++ b/vcl/inc/pdf/XmpMetadata.hxx @@ -20,7 +20,7 @@ namespace vcl::pdf class XmpMetadata { private: - bool mbWritten; + bool mbWritten = false; std::unique_ptr<SvMemoryStream> mpMemoryStream; public: @@ -29,6 +29,10 @@ public: OString msSubject; OString msProducer; OString msPDFVersion; + // For PDF/A-1 to PDF/A-3 this is required and we shall use pdfaid:conformance value B (we don't support A) + // For PDF/A-4 the pdfaid:conformance entry is optional and the only valid values are E or F + // We shall set F if we use embedded files + OString msConformance = "B"_ostr; OString msKeywords; std::vector<OString> maContributor; OString msCoverage; @@ -41,8 +45,8 @@ public: OString m_sCreatorTool; OString m_sCreateDate; - sal_Int32 mnPDF_A; - bool mbPDF_UA; + sal_Int32 mnPDF_A = 0; + bool mbPDF_UA = false; public: XmpMetadata(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 54d079b6e957..6dffb86b6c19 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5825,6 +5825,15 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata() lcl_assignMeta(m_aContext.DocumentInfo.Subject, aMetadata.msSubject); lcl_assignMeta(m_aContext.DocumentInfo.Producer, aMetadata.msProducer); aMetadata.msPDFVersion = getPDFVersionStr(m_aContext.Version); + if (m_nPDFA_Version == 4) + { + // if we have embedded files we need to use conformance level "F" + aMetadata.msConformance = m_aEmbeddedFiles.empty() ? ""_ostr : "F"_ostr; + } + else + { + aMetadata.msConformance = "B"_ostr; + } lcl_assignMeta(m_aContext.DocumentInfo.Keywords, aMetadata.msKeywords); lcl_assignMeta(m_aContext.DocumentInfo.Contributor, aMetadata.maContributor); lcl_assignMeta(m_aContext.DocumentInfo.Coverage, aMetadata.msCoverage); diff --git a/vcl/source/pdf/XmpMetadata.cxx b/vcl/source/pdf/XmpMetadata.cxx index 53bf3902ab2b..24909ae9a519 100644 --- a/vcl/source/pdf/XmpMetadata.cxx +++ b/vcl/source/pdf/XmpMetadata.cxx @@ -23,12 +23,7 @@ constexpr const char* constPadding = " " " "; } -XmpMetadata::XmpMetadata() - : mbWritten(false) - , mnPDF_A(0) - , mbPDF_UA(false) -{ -} +XmpMetadata::XmpMetadata() = default; void XmpMetadata::write() { @@ -58,10 +53,19 @@ void XmpMetadata::write() aXmlWriter.content(sPdfVersion); aXmlWriter.endElement(); - aXmlWriter.startElement("pdfaid:conformance"); - aXmlWriter.content("B"_ostr); - aXmlWriter.endElement(); + if (mnPDF_A == 4) + { + aXmlWriter.startElement("pdfaid:rev"); + aXmlWriter.content("2020"_ostr); + aXmlWriter.endElement(); + } + if (!msConformance.isEmpty()) + { + aXmlWriter.startElement("pdfaid:conformance"); + aXmlWriter.content(msConformance); + aXmlWriter.endElement(); + } aXmlWriter.endElement(); }