vcl/inc/pdf/ResourceDict.hxx | 3 ++- vcl/source/gdi/pdfwriter_impl.cxx | 6 +++--- vcl/source/pdf/ResourceDict.cxx | 24 +++++++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-)
New commits: commit ddeca485638552a0957ac9dba2542e1601d91153 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Dec 17 22:36:12 2024 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Dec 18 10:12:49 2024 +0100 pdf: don't write ProcSet array to resource dictionary for PDF 2.0 /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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/vcl/inc/pdf/ResourceDict.hxx b/vcl/inc/pdf/ResourceDict.hxx index 119d9314f48a..e04f0de9f880 100644 --- a/vcl/inc/pdf/ResourceDict.hxx +++ b/vcl/inc/pdf/ResourceDict.hxx @@ -12,6 +12,7 @@ #include <rtl/strbuf.hxx> #include <map> +#include <vcl/pdfwriter.hxx> namespace vcl::pdf { @@ -31,7 +32,7 @@ struct ResourceDict std::map<OString, sal_Int32> m_aShadings; std::map<OString, sal_Int32> m_aPatterns; - void append(OStringBuffer& rBuffer, sal_Int32 nFontDictObject); + void append(OStringBuffer& rBuffer, sal_Int32 nFontDictObject, PDFWriter::PDFVersion eVersion); }; } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 4c39710abab3..6896e112daf9 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2195,7 +2195,7 @@ bool PDFWriterImpl::emitTilings() aTilingObj.append( "] " ); } 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 " @@ -2662,7 +2662,7 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace, // write resources dict aLine.setLength(0); aLine.append(OString::number(nResources) + " 0 obj "); - aResourceDict.append(aLine, nFontDict); + aResourceDict.append(aLine, nFontDict, m_aContext.Version); aLine.append("endobj "); if (!updateObject(nResources)) return false; @@ -3161,7 +3161,7 @@ sal_Int32 PDFWriterImpl::emitResources() aLine.setLength( 0 ); aLine.append( OString::number(nResourceDict) + " 0 obj " ); - m_aGlobalResourceDict.append( aLine, getFontDictObject() ); + m_aGlobalResourceDict.append(aLine, getFontDictObject(), m_aContext.Version); aLine.append( "endobj " ); CHECK_RETURN( writeBuffer( aLine ) ); 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 <pdf/ResourceDict.hxx> +#include <pdf/COSWriter.hxx> 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("<< "); + COSWriter aWriter(rBuf); + aWriter.startDict(); if (nFontDictObject) - rBuf.append("/Font " + OString::number(nFontDictObject) + " 0 R "); + 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("] >> "); + + 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("] "); + } + aWriter.endDict(); } } // end vcl::pdf