From 899a52b236b81a94367ec8bafdff891a67d818aa Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (Allotropia)" Date: Tue, 6 Jul 2021 10:26:09 +0200 Subject: Disable PDF-to-PDF embedding on PDF export (hack) Due to creating PDF formats recognized as errors for PDF readers using PDF1.5 I decided for a QuickFix to have a simple possibility to disaable that feature, depending on the flag LIBO_ALLOW_PDF_TO_PDF_EMBEDDING If (initially) not defined/set, PDF-to-PDF embedding will be replaced at export to use Jpeg/PixelData instead what is uncritical and creates valid PDF files. If defined/set, all will be unchanged. This opens a quick possibility to switch back if unexpected side effects should occur. Change-Id: I5aaf833b539cdea2bb3bf165cd25990e56efa847 --- vcl/qa/cppunit/pdfexport/pdfexport.cxx | 26 +++++++++++++++++++------- vcl/source/gdi/pdfwriter_impl.cxx | 8 ++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 28b9fc9f3bcc..32288d569728 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -138,20 +138,32 @@ public: void testTdf121615(); void testTocLink(); + // the following tests do *not* work when + // LIBO_ALLOW_PDF_TO_PDF_EMBEDDING is FALSE, so need + // to deactivate those. These are indeed the ones that + // check for reference/form and similar stuff + //BAD CPPUNIT_TEST(testTdf106059); + //BAD CPPUNIT_TEST(testTdf106693); + //BAD CPPUNIT_TEST(testForcePoint71); + //BAD CPPUNIT_TEST(testTdf106972); + //BAD CPPUNIT_TEST(testTdf106972Pdf17); + //BAD CPPUNIT_TEST(testTdf107018); + //BAD CPPUNIT_TEST(testTdf107089); + CPPUNIT_TEST_SUITE(PdfExportTest); - CPPUNIT_TEST(testTdf106059); + // CPPUNIT_TEST(testTdf106059); CPPUNIT_TEST(testTdf105461); CPPUNIT_TEST(testTdf107868); CPPUNIT_TEST(testTdf105093); CPPUNIT_TEST(testTdf106206); - CPPUNIT_TEST(testTdf106693); - CPPUNIT_TEST(testForcePoint71); - CPPUNIT_TEST(testTdf106972); - CPPUNIT_TEST(testTdf106972Pdf17); + // CPPUNIT_TEST(testTdf106693); + // CPPUNIT_TEST(testForcePoint71); + // CPPUNIT_TEST(testTdf106972); + // CPPUNIT_TEST(testTdf106972Pdf17); CPPUNIT_TEST(testSofthyphenPos); CPPUNIT_TEST(testTdf107013); - CPPUNIT_TEST(testTdf107018); - CPPUNIT_TEST(testTdf107089); + // CPPUNIT_TEST(testTdf107018); + // CPPUNIT_TEST(testTdf107089); CPPUNIT_TEST(testTdf99680); CPPUNIT_TEST(testTdf99680_2); CPPUNIT_TEST(testTdf108963); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 1a5f772af2e5..eadd646cb5d1 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -9338,7 +9338,9 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& rGraphic, ReferenceXObject // no pdf data. rEmit.m_nBitmapObject = nBitmapObject; - if (!rGraphic.hasPdfData()) + static bool bAllowPdfToPdf(nullptr != getenv("LIBO_ALLOW_PDF_TO_PDF_EMBEDDING")); + const bool bHasPdfDFata(bAllowPdfToPdf && rGraphic.hasPdfData()); + if (!bHasPdfDFata) return; if (m_aContext.UseReferenceXObject) @@ -9406,7 +9408,9 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const { m_aJPGs.emplace( m_aJPGs.begin() ); JPGEmit& rEmit = m_aJPGs.front(); - if (!rGraphic.hasPdfData() || m_aContext.UseReferenceXObject) + static bool bAllowPdfToPdf(nullptr != getenv("LIBO_ALLOW_PDF_TO_PDF_EMBEDDING")); + const bool bHasPdfDFata(bAllowPdfToPdf && rGraphic.hasPdfData()); + if (!bHasPdfDFata || m_aContext.UseReferenceXObject) rEmit.m_nObject = createObject(); rEmit.m_aID = aID; rEmit.m_pStream = std::move( pStream ); -- cgit