summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-10-31 22:59:30 +0100
committerTomaž Vajngerl <quikee@gmail.com>2024-11-04 21:20:25 +0100
commitcbc51154c02ec7a52a3ad047f3bab1670c9d481a (patch)
tree80714d41999bce521c68d97258890c5dfe0f9d0b /vcl/source/gdi
parent29fb374c5260898b081aa8993bc68f6ab66b6057 (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
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx56
1 files changed, 34 insertions, 22 deletions
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;