summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-12-17 22:36:12 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-12-26 13:52:28 +0100
commit93fe2327a156eafc14ea1faf01028fd20f5ed5a0 (patch)
treebf7732ec4a194ca903b4484b8c992375b190db0b /vcl/source
parentb3f2491d7cb14ca9a87e8610dfdcf8e8a86d7a9f (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178777 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx6
-rw-r--r--vcl/source/pdf/ResourceDict.cxx24
2 files changed, 20 insertions, 10 deletions
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 <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("<<\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