diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-10-31 22:59:30 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-11-04 21:20:25 +0100 |
commit | cbc51154c02ec7a52a3ad047f3bab1670c9d481a (patch) | |
tree | 80714d41999bce521c68d97258890c5dfe0f9d0b | |
parent | 29fb374c5260898b081aa8993bc68f6ab66b6057 (diff) |
pdf: initial PDF 2.0 and PDF/A-4 support
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 <quikee@gmail.com>
Tested-by: Jenkins
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 17 | ||||
-rw-r--r-- | include/vcl/pdfwriter.hxx | 16 | ||||
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 15 | ||||
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 11 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 56 |
5 files changed, 84 insertions, 31 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 470a53cc38c5..8c42ebb7a5fa 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -754,21 +754,29 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& aContext.Version = vcl::PDFWriter::PDFVersion::PDF_1_7; break; case 1: - aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_1; + aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_1; bUseTaggedPDF = true; // force the tagged PDF as well mbRemoveTransparencies = true; // does not allow transparencies bEncrypt = false; // no encryption xEnc.clear(); break; case 2: - aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_2; + aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_2; bUseTaggedPDF = true; // force the tagged PDF as well mbRemoveTransparencies = false; // does allow transparencies bEncrypt = false; // no encryption xEnc.clear(); break; case 3: - aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_3; + aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_3; + bUseTaggedPDF = true; // force the tagged PDF as well + mbRemoveTransparencies = false; // does allow transparencies + bEncrypt = false; // no encryption + xEnc.clear(); + break; + case 4: + // TODO - determine what is allowed for PDFA/4 + aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_4; bUseTaggedPDF = true; // force the tagged PDF as well mbRemoveTransparencies = false; // does allow transparencies bEncrypt = false; // no encryption @@ -783,6 +791,9 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& case 17: aContext.Version = vcl::PDFWriter::PDFVersion::PDF_1_7; break; + case 20: + aContext.Version = vcl::PDFWriter::PDFVersion::PDF_2_0; + break; } // PDF/UA support diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 90d1a48754d1..2d6c517dc7ba 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -99,8 +99,20 @@ public: enum class Orientation { Portrait, Inherit }; - // in case the below enum is added PDF_2_0, please add just after PDF_1_7 - enum class PDFVersion { PDF_1_4, PDF_1_5, PDF_1_6, PDF_1_7, PDF_A_1, PDF_A_2, PDF_A_3 };//i59651, PDF/A-1b & -1a, only -1b implemented for now + + enum class PDFVersion + { + PDF_1_4, + PDF_1_5, + PDF_1_6, + PDF_1_7, + PDF_2_0, + PDF_A_1, + PDF_A_2, + PDF_A_3, + PDF_A_4, // Based on PDF 2.0 + }; //i59651, PDF/A-1b & -1a, only -1b implemented for now + // for the meaning of DestAreaType please look at PDF Reference Manual // version 1.4 section 8.2.1, page 475 enum class DestAreaType { XYZ, FitRectangle }; diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 74d4be9d1d2d..40eaaa6978c3 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5058,6 +5058,11 @@ <desc>PDF 1.7</desc> </info> </enumeration> + <enumeration oor:value="20"> + <info> + <desc>PDF 2.0</desc> + </info> + </enumeration> <enumeration oor:value="1"> <info> <desc>PDF/A-1 (ISO 19005-1:2005)</desc> @@ -5068,6 +5073,16 @@ <desc>PDF/A-2 (ISO 19005-2:2011)</desc> </info> </enumeration> + <enumeration oor:value="3"> + <info> + <desc>PDF/A-3 (ISO 19005-3:2012)</desc> + </info> + </enumeration> + <enumeration oor:value="4"> + <info> + <desc>PDF/A-4 (ISO 19005-4)</desc> + </info> + </enumeration> </constraints> <value>0</value> </prop> diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index b92be41c9622..df86ea640e96 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -1087,14 +1087,17 @@ i12626 void drawEmphasisMark( tools::Long nX, tools::Long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const tools::Rectangle& rRect1, const tools::Rectangle& rRect2 ); /* true if PDF/A-1a or PDF/A-1b is output */ - bool m_bIsPDF_A1; + bool m_bIsPDF_A1 = false; /* true if PDF/A-2a is output */ - bool m_bIsPDF_A2; + bool m_bIsPDF_A2 = false; + /* true if PDF/A-3 is output */ + bool m_bIsPDF_A3 = false; + /* true if PDF/A-4 is output */ + bool m_bIsPDF_A4 = false; /* PDF/UA support enabled */ - bool m_bIsPDF_UA; + bool m_bIsPDF_UA = false; - bool m_bIsPDF_A3; PDFWriter& m_rOuterFace; 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( "<</Type/Annot" ); - if( m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3) + if (m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4) aLine.append( "/F 4" ); aLine.append( "/Subtype/Link/Border[0 0 0]/Rect[" ); @@ -4077,7 +4087,7 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry c // 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 - if (m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3) + if (m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4) aLine.append("/F 4 "); aLine.append("/Popup "); @@ -4686,7 +4696,7 @@ bool PDFWriterImpl::emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDi // PDF/A requires sub-dicts for /FT/Btn objects (clause // 6.3.3) - if( m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3) + if( m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4) { if( rWidget.m_eType == PDFWriter::RadioButton || rWidget.m_eType == PDFWriter::CheckBox || @@ -5067,7 +5077,7 @@ bool PDFWriterImpl::emitWidgetAnnotations() } if( rWidget.m_eType == PDFWriter::PushButton ) { - if(!m_bIsPDF_A1) + if (!m_bIsPDF_A1) { OStringBuffer aDest; if( rWidget.m_nDest != -1 && appendDest( m_aDestinationIdTranslation[ rWidget.m_nDest ], aDest ) ) @@ -5593,7 +5603,7 @@ bool PDFWriterImpl::emitCatalog() aLine.append( getResourceDictObj() ); aLine.append( " 0 R" ); // NeedAppearances must not be used if PDF is signed - if( m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 + if(m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4 #if HAVE_FEATURE_NSS || ( m_nSignatureObject != -1 ) #endif @@ -5910,7 +5920,7 @@ sal_Int32 PDFWriterImpl::emitNamedDestinations() // emits the output intent dictionary sal_Int32 PDFWriterImpl::emitOutputIntent() { - if( !m_bIsPDF_A1 && !m_bIsPDF_A2 && !m_bIsPDF_A3 ) + if (!m_bIsPDF_A1 && !m_bIsPDF_A2 && !m_bIsPDF_A3 && !m_bIsPDF_A4) return 0; //emit the sRGB standard profile, in ICC format, in a stream, per IEC61966-2.1 @@ -6013,7 +6023,7 @@ static void lcl_assignMeta(const css::uno::Sequence<OUString>& 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; |