summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-03 20:23:23 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-02-06 13:00:12 +0100
commitc1a79354e6ae96a287095abcfc53f41aa2d43358 (patch)
treedb6bd3b9206a807915980b1902a2a6c17272f717 /vcl
parentd037d971b4f4f408c7a6b6c15a0c7e742f61d354 (diff)
tdf#129976 PDF export of PDF images: adapt transparency to rendering
The bugdoc has a transparent PDF image, and we currently put a white background behind that in Impress, given that vcl::RenderPDFBitmaps() works with Bitmap instances, not BitmapEx ones. This means that in case we preserve transparency during PDF export, the content that was rendered OK now becomes unreadable. Adapt the PDF export to do the same as rendering by putting a white background behind the PDF image. (cherry picked from commit 7088140dbf1d5e0391c2662f0213018a45620ff9) Change-Id: I4edcb12fab71bb305d97a50d20fbfbf86d9aab85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87956 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx5
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx10
2 files changed, 13 insertions, 2 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 02e597c76dd5..1603cc83a8e5 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1906,8 +1906,9 @@ void PdfExportTest::testPdfImageResourceInlineXObjectRef()
CPPUNIT_ASSERT_EQUAL(1, FPDFPage_CountObjects(pPdfPage.get()));
FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage.get(), 0);
CPPUNIT_ASSERT_EQUAL(FPDF_PAGEOBJ_FORM, FPDFPageObj_GetType(pPageObject));
- CPPUNIT_ASSERT_EQUAL(1, FPDFFormObj_CountObjects(pPageObject));
- FPDF_PAGEOBJECT pFormObject = FPDFFormObj_GetObject(pPageObject, 0);
+ // 2: white background and the actual object.
+ CPPUNIT_ASSERT_EQUAL(2, FPDFFormObj_CountObjects(pPageObject));
+ FPDF_PAGEOBJECT pFormObject = FPDFFormObj_GetObject(pPageObject, 1);
CPPUNIT_ASSERT_EQUAL(FPDF_PAGEOBJ_FORM, FPDFPageObj_GetType(pFormObject));
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 83d5c75bc912..72919042f0a2 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9001,6 +9001,16 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
// Reset line width to the default.
aStream.append(" 1 w\n");
+ // vcl::RenderPDFBitmaps() effectively renders a white background for transparent input, be
+ // consistent with that.
+ aStream.append("1 1 1 rg\n");
+ aStream.append("0 0 ");
+ aStream.append(aSize.Width());
+ aStream.append(" ");
+ aStream.append(aSize.Height());
+ aStream.append(" re\n");
+ aStream.append("f*\n");
+
// No reference XObject, draw the form XObject containing the original
// page streams.
aStream.append("/Im");