From cbc51154c02ec7a52a3ad047f3bab1670c9d481a Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 31 Oct 2024 22:59:30 +0100 Subject: pdf: initial PDF 2.0 and PDF/A-4 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added PDF 2.0 and PDF/A-4 version to enums. Write the PDF 2.0 support for the file headers. Add the identical considitons as for the PDF/A-4 as they were for PDF/A-3. Change-Id: Iccf5afbf09c4cd0cd1ae7122c860e8cbefe3a6fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176023 Reviewed-by: Tomaž Vajngerl Tested-by: Jenkins --- vcl/source/gdi/pdfwriter_impl.cxx | 56 ++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'vcl/source/gdi') diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index ba5f3faafd5b..ce3d102d5c55 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -642,6 +642,10 @@ const char* getPDFVersionStr(PDFWriter::PDFVersion ePDFVersion) case PDFWriter::PDFVersion::PDF_A_3: case PDFWriter::PDFVersion::PDF_1_7: return "1.7"; + // PDF 2.0 + case PDFWriter::PDFVersion::PDF_A_4: + case PDFWriter::PDFVersion::PDF_2_0: + return "2.0"; } } @@ -1251,10 +1255,6 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, m_nRC4KeyLength(0), m_bEncryptThisStream( false ), m_nAccessPermissions(0), - m_bIsPDF_A1( false ), - m_bIsPDF_A2( false ), - m_bIsPDF_UA( false ), - m_bIsPDF_A3( false ), m_rOuterFace( i_rOuterFace ) { m_aStructure.emplace_back( ); @@ -1330,17 +1330,27 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, // insert outline root m_aOutline.emplace_back( ); - m_bIsPDF_A1 = (m_aContext.Version == PDFWriter::PDFVersion::PDF_A_1); - if( m_bIsPDF_A1 ) - m_aContext.Version = PDFWriter::PDFVersion::PDF_1_4; //meaning we need PDF 1.4, PDF/A flavour - - m_bIsPDF_A2 = (m_aContext.Version == PDFWriter::PDFVersion::PDF_A_2); - if( m_bIsPDF_A2 ) - m_aContext.Version = PDFWriter::PDFVersion::PDF_1_7; - - m_bIsPDF_A3 = (m_aContext.Version == PDFWriter::PDFVersion::PDF_A_3); - if( m_bIsPDF_A3 ) - m_aContext.Version = PDFWriter::PDFVersion::PDF_1_7; + switch (m_aContext.Version) + { + case PDFWriter::PDFVersion::PDF_A_1: + m_bIsPDF_A1 = true; + m_aContext.Version = PDFWriter::PDFVersion::PDF_1_4; //meaning we need PDF 1.4, PDF/A flavour + break; + case PDFWriter::PDFVersion::PDF_A_2: + m_bIsPDF_A2 = true; + m_aContext.Version = PDFWriter::PDFVersion::PDF_1_7; + break; + case PDFWriter::PDFVersion::PDF_A_3: + m_bIsPDF_A3 = true; + m_aContext.Version = PDFWriter::PDFVersion::PDF_1_7; + break; + case PDFWriter::PDFVersion::PDF_A_4: + m_bIsPDF_A4 = true; + m_aContext.Version = PDFWriter::PDFVersion::PDF_2_0; + break; + default: + break; + } if (m_aContext.UniversalAccessibilityCompliance) { @@ -3731,7 +3741,7 @@ bool PDFWriterImpl::emitLinkAnnotations() // i59651: key /F set bits Print to 1 rest to 0. We don't set NoZoom NoRotate to 1, since it's a 'should' // see PDF 8.4.2 and ISO 19005-1:2005 6.5.3 aLine.append( "<& rValues, std::vec // emits the document metadata sal_Int32 PDFWriterImpl::emitDocumentMetadata() { - if( !m_bIsPDF_A1 && !m_bIsPDF_A2 && !m_bIsPDF_A3 && !m_bIsPDF_UA) + if( !m_bIsPDF_A1 && !m_bIsPDF_A2 && !m_bIsPDF_A3 && !m_bIsPDF_A4 && !m_bIsPDF_UA) return 0; //get the object number for all the destinations @@ -6029,6 +6039,8 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata() aMetadata.mnPDF_A = 2; else if (m_bIsPDF_A3) aMetadata.mnPDF_A = 3; + else if (m_bIsPDF_A4) + aMetadata.mnPDF_A = 4; aMetadata.mbPDF_UA = m_bIsPDF_UA; -- cgit