From 93fe2327a156eafc14ea1faf01028fd20f5ed5a0 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Tue, 17 Dec 2024 22:36:12 +0900 Subject: pdf: don't write ProcSet array to resource dictionary for PDF 2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /ProcSet is deprecated in PDF 2.0 so don't write it to the PDF stream if the output is PDF 2.0. Change-Id: Id65e60bd68e42c26f4ba5a590fbc383aa2eb23bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178673 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178777 Reviewed-by: Tomaž Vajngerl Tested-by: Jenkins --- vcl/source/gdi/pdfwriter_impl.cxx | 6 +++--- vcl/source/pdf/ResourceDict.cxx | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 84e40b463fe9..69e9740b9a3b 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2218,7 +2218,7 @@ bool PDFWriterImpl::emitTilings() aTilingObj.append( "]\n" ); } aTilingObj.append( "/Resources" ); - tiling.m_aResources.append( aTilingObj, getFontDictObject() ); + tiling.m_aResources.append(aTilingObj, getFontDictObject(), m_aContext.Version); if( bDeflate ) aTilingObj.append( "/Filter/FlateDecode" ); aTilingObj.append( "/Length " @@ -2688,7 +2688,7 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace, // write resources dict aLine.setLength(0); aLine.append(OString::number(nResources) + " 0 obj\n"); - aResourceDict.append(aLine, nFontDict); + aResourceDict.append(aLine, nFontDict, m_aContext.Version); aLine.append("endobj\n\n"); if (!updateObject(nResources)) return false; @@ -3192,7 +3192,7 @@ sal_Int32 PDFWriterImpl::emitResources() aLine.setLength( 0 ); aLine.append( OString::number(nResourceDict) + " 0 obj\n" ); - m_aGlobalResourceDict.append( aLine, getFontDictObject() ); + m_aGlobalResourceDict.append(aLine, getFontDictObject(), m_aContext.Version); aLine.append( "endobj\n\n" ); if (!writeBuffer(aLine)) return 0; return nResourceDict; diff --git a/vcl/source/pdf/ResourceDict.cxx b/vcl/source/pdf/ResourceDict.cxx index f4647cb38335..f19a428a6283 100644 --- a/vcl/source/pdf/ResourceDict.cxx +++ b/vcl/source/pdf/ResourceDict.cxx @@ -9,6 +9,7 @@ */ #include +#include namespace vcl::pdf { @@ -40,19 +41,28 @@ void appendResourceMap(OStringBuffer& rBuf, const char* pPrefix, } } -void ResourceDict::append(OStringBuffer& rBuf, sal_Int32 nFontDictObject) +void ResourceDict::append(OStringBuffer& rBuf, sal_Int32 nFontDictObject, + PDFWriter::PDFVersion eVersion) { - rBuf.append("<<\n"); + COSWriter aWriter(rBuf); + aWriter.startDict(); if (nFontDictObject) - rBuf.append("/Font " + OString::number(nFontDictObject) + " 0 R\n"); + aWriter.writeKeyAndReference("/Font", nFontDictObject); appendResourceMap(rBuf, "XObject", m_aXObjects); appendResourceMap(rBuf, "ExtGState", m_aExtGStates); appendResourceMap(rBuf, "Shading", m_aShadings); appendResourceMap(rBuf, "Pattern", m_aPatterns); - rBuf.append("/ProcSet[/PDF/Text"); - if (!m_aXObjects.empty()) - rBuf.append("/ImageC/ImageI/ImageB"); - rBuf.append("]\n>>\n"); + + if (eVersion < PDFWriter::PDFVersion::PDF_2_0) + { + rBuf.append("/ProcSet"); + rBuf.append("["); + rBuf.append("/PDF/Text"); + if (!m_aXObjects.empty()) + rBuf.append("/ImageC/ImageI/ImageB"); + rBuf.append("]\n"); + } + aWriter.endDict(); } } // end vcl::pdf -- cgit