diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-22 15:31:28 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-22 17:29:21 +0100 |
commit | 6db0f1feb1d9931d2726dd11a889c58815710ce0 (patch) | |
tree | fef035acbd6f2e332787b633749bb0f899409d56 | |
parent | f28672a077375a360879ad34edfbd06b611ea6d8 (diff) |
tdf#106059 PDF export: create a reference XObject for PDF images
If a reader is capable of showing reference XObjects, then it can show
the original/vector PDF image instead of the bitmap fallback.
Change-Id: Iac8a460c43ff7467e3a5fd8ee4cbf2179084335b
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 20 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl2.cxx | 7 |
3 files changed, 21 insertions, 11 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index be69ad0bba9c..fd63cdd1c5d2 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -11178,7 +11178,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) } // Write the form XObject proxy for the image. - if (rObject.m_nFormObject > 0) + if (rObject.m_nFormObject > 0 && rObject.m_nEmbeddedObject > 0) { aLine.setLength(0); if (!updateObject(rObject.m_nFormObject)) @@ -11215,8 +11215,14 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.append(aSize.Width()); aLine.append(" "); aLine.append(aSize.Height()); - aLine.append(" ]"); - aLine.append(" /Length "); + aLine.append(" ]\n"); + + // Write the reference dictionary. + aLine.append("/Ref<< /F << /Type /Filespec /F (<embedded file>) /EF << /F "); + aLine.append(rObject.m_nEmbeddedObject); + aLine.append(" 0 R >> >> /Page 0 >>\n"); + + aLine.append("/Length "); OStringBuffer aStream; aStream.append("q "); @@ -11400,7 +11406,15 @@ const PDFWriterImpl::BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx m_aBitmaps.front().m_aBitmap = aBitmap; m_aBitmaps.front().m_nObject = createObject(); if (rGraphic.getPdfData().hasElements()) + { + // Store the original PDF data as an embedded file. + m_aEmbeddedFiles.push_back(PDFEmbeddedFile()); + m_aEmbeddedFiles.back().m_nObject = createObject(); + m_aEmbeddedFiles.back().m_aData = rGraphic.getPdfData(); + m_aBitmaps.front().m_nFormObject = createObject(); + m_aBitmaps.front().m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject; + } it = m_aBitmaps.begin(); } diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 69338bd62867..022679fda687 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -215,10 +215,13 @@ public: sal_Int32 m_nObject; /// ID of the Form XObject, if any. sal_Int32 m_nFormObject; + /// ID of the embedded object, if m_nFormObject is used. + sal_Int32 m_nEmbeddedObject; BitmapEmit() : m_nObject(0), - m_nFormObject(0) + m_nFormObject(0), + m_nEmbeddedObject(0) { } diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index f131a6d2b899..6de2a88c9c92 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -248,13 +248,6 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx ); else m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic ); - - if (i_Graphic.getPdfData().hasElements()) - { - m_aEmbeddedFiles.push_back(PDFEmbeddedFile()); - m_aEmbeddedFiles.back().m_nObject = createObject(); - m_aEmbeddedFiles.back().m_aData = i_Graphic.getPdfData(); - } } } } |