Bug 108726 - inserted PDF images lose transparency in 5.4
Summary: inserted PDF images lose transparency in 5.4
Status: RESOLVED DUPLICATE of bug 106581
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
5.4.0.0.beta2
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: PDF-Import-Draw
  Show dependency treegraph
 
Reported: 2017-06-24 07:30 UTC by Callegar
Modified: 2020-10-28 23:17 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Test pdf file with no background (1.15 KB, application/pdf)
2017-07-03 14:23 UTC, Callegar
Details
EMF file equivalent to PDF file (obtained by inkscape) (1.22 KB, image/x-emf)
2017-07-03 14:24 UTC, Callegar
Details
Drawing prepared with libo 5.4.0.1, with both the pdf and the emf image inserted in the drawing (14.99 KB, application/vnd.oasis.opendocument.graphics)
2017-07-03 14:29 UTC, Callegar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Callegar 2017-06-24 07:30:43 UTC
Hi,

just tested LibO 5.4 RC, with interest in the new management of PDF files during import.

I see a very nice and commendable effort at providing a faithful and fast rendering of PDF images inserted in documents, drawing and presentations, thanks!

At the same time, I also see some quite notable regressions:

1) PDF images with a transparent background are always rendered with a white solid background, which makes the PDF import completely useless when the imported image needs to appear on a colored or otherwise non-white background. This is extremely critical in some workflows.

2) The "break" action is now missing for PDF images in draw and impress. Ideally, this should still be present and transform the image in elementary LibO drawing primitives (even not perfectly), as it happens for windows metafiles. Notably, LibO already includes a codepath for doing so, since PDF images are converted in LibO drawing primitives when /opened/ rather than imported.

I hope that this can be fixed before the 5.4 final release.
Comment 1 m_a_riosv 2017-06-24 12:07:47 UTC Comment hidden (obsolete)
Comment 2 Callegar 2017-07-03 14:23:41 UTC
Created attachment 134454 [details]
Test pdf file with no background
Comment 3 Callegar 2017-07-03 14:24:12 UTC
Created attachment 134455 [details]
EMF file equivalent to PDF file (obtained by inkscape)
Comment 4 Callegar 2017-07-03 14:29:03 UTC
Created attachment 134456 [details]
Drawing prepared with libo 5.4.0.1, with both the pdf and the emf image inserted in the drawing
Comment 5 Callegar 2017-07-03 14:30:22 UTC
Point 1: in the example, note how the PDF once inserted as an image in LibO draw includes a white background, when it should not (the PDF image has no background).
Comment 6 Callegar 2017-07-03 14:32:39 UTC
Point 2. Open the demo.odg file with LibO 5.3. Select the oval above the "PDF" text. Right click and see that a contextual menu appears with the "Break" option in it. Do the same with LibO 5.4. There is no "Break" option.
Comment 7 V Stuart Foote 2017-08-25 05:49:12 UTC
Confirming both aspects on Windows 10 Pro 64-bit en-US with
Version: 5.4.0.3 (x64)
Build ID: 7556cbc6811c9d992f4064ab9287069087d7f62c
CPU threads: 8; OS: Windows 6.19; UI render: default; 
Locale: en-US (en_US); Calc: group

But I think the loss of the "break" was expected with adoption of the pdfium based insertion. I think return of break would requires enhancement as in bug 106581 to use Skia graphics with the pdfium filtered PDF.

A PDF file filter import opened into Draw still support the "break".

@Miklos?
Comment 8 Callegar 2017-08-25 13:56:17 UTC
> I think return of break would requires enhancement as in bug 106581 to use Skia graphics with the pdfium filtered PDF.

Wouldn't it be possible, at least for the time being, leaving in place and leveraging the 5.3 codepath for the "break", until it is possible to switch to use Skia graphics with the pdfium filtered PDF?

> A PDF file filter import opened into into Draw still support the "break".

If you "open" the pdf file with draw, in opposition to "inserting" it into an existing draw document, then the conversion into native LibO objects is automatic (opposed to showing the image rendered by pdfium), which is why the "break" action remains supported, I think.

Indeed, the possibility of getting this behavior through the "opening" of the pdf document in draw is a useful workaround for the lack of "break" option when inserting the pdf image in an existing drawing/presentation. Another workaround is to open in inkscape, save as emf and insert the emf that supports the break action. Still, it seems a bit more complex than desirable and a bit inconsistent to have break on all vector formats (svg, emf, wmf, native metafile), but PDF.
Comment 9 V Stuart Foote 2017-08-25 15:11:54 UTC
(In reply to sergio.callegari from comment #8)
> > I think return of break would requires enhancement as in bug 106581 to use Skia graphics with the pdfium filtered PDF.
> 
> Wouldn't it be possible, at least for the time being, leaving in place and
> leveraging the 5.3 codepath for the "break", until it is possible to switch
> to use Skia graphics with the pdfium filtered PDF?
> 

As in your original posting in bug 104648, _no_. 

Miklos' work on an "insert as image" capability (resolving bug 89727) and then moving it to a pdfium based filter simply does not support it.

> > A PDF file filter import opened into into Draw still support the "break".
> 
> If you "open" the pdf file with draw, in opposition to "inserting" it into
> an existing draw document, then the conversion into native LibO objects is
> automatic (opposed to showing the image rendered by pdfium), which is why
> the "break" action remains supported, I think.
> 

Yes that is correct, but the PDF structure is lost losing fidelity when printing or reexporting out of the saved ODF drawing.

> Indeed, the possibility of getting this behavior through the "opening" of
> the pdf document in draw is a useful workaround for the lack of "break"
> option when inserting the pdf image in an existing drawing/presentation.
> Another workaround is to open in inkscape, save as emf and insert the emf
> that supports the break action. Still, it seems a bit more complex than
> desirable and a bit inconsistent to have break on all vector formats (svg,
> emf, wmf, native metafile), but PDF.

There are better ghostscript based PDF conversions than Inkscape--but that is one approach.
Comment 10 Miklos Vajna 2017-08-31 14:23:55 UTC
(In reply to V Stuart Foote from comment #7)
> @Miklos?

Transparent PDF looks doable.

"break" -- as you said -- still possible with manually opening in Draw and copying the draw page. Out-of-the-box break is possible, but a rather large work. It would require LO providing a skia interface, also pdfium's skia output (the only vector one) is not yet ready.

So I guess let's keep this bug open for the transparency part.
Comment 11 Callegar 2017-12-28 12:34:52 UTC Comment hidden (obsolete)
Comment 12 Callegar 2018-02-13 15:18:30 UTC
Solid background still present as of 6.0.1 RC 1.

Would be great to get a transparent background when the input PDF has no background through LibO 6.

Such feature would be great particularly for presentations. Also it could allow simplification and enhancements in extensions such as the popular TeXMaths.
Comment 13 Callegar 2018-12-21 21:55:52 UTC Comment hidden (obsolete)
Comment 14 Timur 2020-10-28 07:48:28 UTC
If I understand this bug, claim is that attached PDF has transparent background.
But I see it solid in PDF viewer. Please explain how it can be seen?
Comment 15 Telesto 2020-10-28 08:36:17 UTC
(In reply to Timur from comment #14)
> If I understand this bug, claim is that attached PDF has transparent
> background.
> But I see it solid in PDF viewer. Please explain how it can be seen?

Get the impression this being going to be: PDF export not exporting transparency
Comment 16 Callegar 2020-10-28 19:43:39 UTC
To clarify, this bug is about /import/ of PDF into LibO, not /export/ from LibO.

To get the issue relevance it is better to first make an example that does not use PDF images. Suppose that you are preparing a slide and you have a red background or some background objects. If you insert on it a bitmap image with some lines on a transparent background, you will see just those lines on the background elements of the slides. However if you insert an image with a non-transparent background (e.g. white), your slide will look ugly, because you'll get a big white box with the lines overlapped covering your slide background or your background objects.

Same goes with PDF, but with some difference because this is a vector format. Rather than having a transparent background, in PDF you typically have no background at all, you just have the data about the foreground objects (e.g. the lines). When you import a PDF image with some lines and no background into a slide with a red background or some background elements, you expect to see just the lines on the background, not a big white box with the lines covering all the background elements.

The problem is in the way in which recent LibO treats PDF by first transforming it into a bitmap for visualization. When the PDF has no background, rather than creating a bitmap with a transparent background, a bitmap with a white non-transparent background is created. And thus you get the ugly white boxes hiding the background elements.

There are many ways to check if a PDF image has a background or not. I think that LibO itself is OK to make the test:
(i) take the PDF file (say the demo PDF file attached to this bug) and /open/ it with LibO, rather than /importing it as an image/ (e.g., launch 'libreoffice demo.pdf'); 
(ii) go to Page->Properties and set all the margins to 0 (LibO may complain a little, but do not worry about it)
(iii) again in Page->Properties set a solid background color (e.g., red). If you see that color in the image, then the image has no background. In fact, the LibO page background that is behind the image can "pass through". Conversely, if the PDF image has a background you will see that background and the LibO page background will not pass through.
Comment 17 V Stuart Foote 2020-10-28 23:17:28 UTC

*** This bug has been marked as a duplicate of bug 106581 ***