diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-01-07 12:23:34 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-01-07 14:59:22 +0100 |
commit | 1984a5c140cc3c7c291047dacf3bddd7061d2047 (patch) | |
tree | b19074fbce1ffdf0be4d4e3a4777a949f391ffa4 /vcl/qa | |
parent | 7df337b3636f9df9bf05d7f493e6c89e43c3f5ca (diff) |
PDF export of PDF images: preserve hyperlinks
The input file has a single page, with a full-page PDF image, which
contains a hyperlink. Similar to pdfcrop, we used to wrap this into a
form XObject, so page-level annotations like hyperlinks were lost.
Explicitly merge page-level annotations from the source page to the page
that contains the PDF image to preserve those annotations.
Change-Id: I96e8bc9d33440b91f3514486d6a8bd75047546b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128108
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/pdf-image-hyperlink.odg | bin | 0 -> 28633 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 18 |
2 files changed, 18 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/pdf-image-hyperlink.odg b/vcl/qa/cppunit/pdfexport/data/pdf-image-hyperlink.odg Binary files differnew file mode 100644 index 000000000000..aa0f89300b2c --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/pdf-image-hyperlink.odg diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index af5f396db14d..7c6e273bf173 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2872,6 +2872,24 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145873) CPPUNIT_ASSERT_DOUBLES_EQUAL(3.49, pObject->getBounds().getHeight(), 0.1); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfImageHyperlink) +{ + // Given a Draw file, containing a PDF image, which has a hyperlink in it: + aMediaDescriptor["FilterName"] <<= OUString("draw_pdf_Export"); + + // When saving to PDF: + saveAsPDF(u"pdf-image-hyperlink.odg"); + + // Then make sure that link is preserved: + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport(); + CPPUNIT_ASSERT(pPdfDocument); + std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); + CPPUNIT_ASSERT(pPdfPage); + // Without the accompanying fix in place, this test would have failed, the hyperlink of the PDF + // image was lost. + CPPUNIT_ASSERT(pPdfPage->hasLinks()); +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); |