missing (masked) images from pdf export

Bug #427540 reported by Gordon on 2009-09-10
This bug affects 17 people
Affects Status Importance Assigned to Milestone

Bug Description

This relates to Inkscape 0.46 running on Windows XP Professional Service Pack 2.

It may be related to these bugs but doesn't match exactly:
  Bug #231160: Saving an imported PDF,as SVG doesn't work
  Bug #291416: SVG from imported PDF cannot be reopened, characters error
  Bug #297701: Cannot open SVG file that was saved from a PDF opened with "Embed
 Images" option set (duplicate of 291416)
  Bug #297702: Cannot open SVG file that was saved from a PDF opened with "Embed
 Images" option set
  Bug #385267 Rectangles with images and pure images get changed during PDF-Expo

        I opened a multi-page pdf in Inkscape, and then saved a single page as both an svg (one-saved-after-opening-original-pdf.svg) and as a pdf (one-saved-by-inkscape.pdf). The svg file opens properly (unlike bug #297701) inside of Inkscape.
        But both Inkscape and Adobe Acrobat Reader 8.0 show the pdf file with most of the images replaced with solid black rectangles. This seems related to the misplaced image files in bug #297701.

theAdib (theadib) on 2009-09-12
tags: added: exporting pdf
Alvin Penner (apenner) wrote :

confirmed on Windows XP, Inkscape 0.46.

on Inkscape 0.47pre2 the problem is different, namely the image is left blank.
Attached is a simplified version of the svg file with only Fig 1 present.

Alvin Penner (apenner) wrote :

the best pdf output I can get here is the attached pdf file in which the image is blank and the file size is rather large

Changed in inkscape:
status: New → Confirmed
Alvin Penner (apenner) wrote :

In Inkscape 0.47pre2, the missing image is related to the use of a mask in the svg file. To see the effect of the mask:
- open the XML editor, select the rectangle rect143,
- note that the gui status bar says that the rectangle is masked
- unmask it using the menu item Object>Mask>Release
- the black/white colors invert on the screen
- export to pdf as attached
- and the pdf is now an accurate rendition of the svg image.

Alvin Penner (apenner) on 2009-09-12
summary: - missing images from pdf export
+ missing (masked) images from pdf export
Gordon (gferris434) wrote :

Thank you very much; you're right. If I unmask all the rectangles (4 in this document) then the images are no longer missing. And in Inkscape 0.46, then one has to reverse the colors by:
1. Choose menu item Effects -> Raster -> Negate

However the svg document doesn't require any of this unmasking (or negating), and both the svg and pdf document are created by Inkscape from the same imported image. So why does all this unmasking need to be done but only for the pdf?

Also note that importing a pdf seems to change the font or spacing on images contained within the pdf; see bug #429709 "changed font or text in pdf import".

su_v (suv-lp) wrote :

reproduced with Inkscape 0.47+devel r9440 on OS X 10.5.8

The images in the exported PDF are not missing but appear to be incorrectly (?) scaled.

The problem does not seem to be using inverted B&W images as masks per se, but related to the preserved (nested) transformation(s) applied to the parent group of the masked rectangle (scale and translate to correct position in the page layout) and the masked rectangle itself (vertically flipped): If - before exporting to PDF - I ungroup and regroup that innermost group again (so that the parent transformation matrix is combined with the 'flipping' matrix of the masked rectangle itself), the image is rendered correctly scaled in the PDF file - but is strongly pixelated.

Changed in inkscape:
importance: Undecided → Medium
Kjohrf (kjohrf) wrote :

I'm having the same problem on 0.48 for a project that has to go out the door today.

There is a linked image that has a grayscale mask. PNG looks file - some of the
image is faded out towards one corner. On PDF output, I don't see the image -
just something vaguely like he mask.

Giorgi Maghlakelidze (dracid) wrote :

Same frustrating problem here...
Windows7 x64, Inkscape 0.48.1

Fixing this problem would be a lifesaver in many situations, where (for example) masking makes the bitmap transparent...
Negating the original bitmap isn't really that effective in this case. :S

My and other people's great thanks go to the person who fixes this... :)

Jason Merkin (jjmerkin) wrote :

I had a similar problem (where objects with a mask were missing or mangled during pdf export) and found a workaround. I found this open bug while googling the issue, so I figured I would share it in case other people have the issue before it is fixed.

I exported just the object by right clicking it and exporting it to a file, then opened that file and replaced the original object with the version from the file. I don't think this is ideal, but it worked in my situation.

version: Inkscape 0.48+devel r11533 (Jul 11 2012)

jazzynico (jazzynico) wrote :

Not fixed on Windows XP, Inkscape trunk revision 12380.

Changed in inkscape:
status: Confirmed → Triaged
tags: added: masking
skierpage (skierpage) wrote :

This is still happening with Inkscape 0.48.4 on Ubuntu 14.04.

My case is I'm opening bank statement PDFs in Inkscape. They look fine in Inkscape, but when I save as PDF or print to a PDF file, the images (bank's logo, next page icon, etc.) don't appear and black squares or gradients appear in their place.

The workaround is much as in comments 5 and 6: select an image, ungroup, select again, right click > Release Mask. The image inverts, so Extensions > Raster > Negate. This leaves faint black outlines but at least the images appear in the PDF.

FWIW the originating PDF is generated by Author: TrilliCom LLC, Producer: TRCA2P14 V1.39C (and some poor drone at the bank fiddling around with its logos until the original PDF looked OK).

confirmed on Inkscape 0.48.5 r10040 on Debian 3.14.15-2 (2014-08-09) x86_64 GNU/Linux

Rick Leijssen (rick-leijssen) wrote :

If I understand correctly, this bug is still present in 0.92.1 r15371 on Windows 7.
I attached a file that gave me this problem; the red shape was generated by matplotlib in python (with rasterized=True).

1) Saving this as pdf, the red shape does not show up at all. Workaround: Select the red shape, Ungroup.
(This could to be related to bugs #605151, #1457791, #1258265, #1285487, #1446992, #1571176 )

2) When saving the resulting file as pdf, the red shape shows weird white distortions. Workaround: Select the red shape, right click, release mask; then select the black&white mask and delete it.
(This could be related to bug #1625633, as well as some of the ones I mentioned above)

The resulting file after these two workarounds looks as I expected.

Since the mask was apparently automatically created by matplotlib, it took me ages to figure out that there was a mask to begin with, which could be the problem.

Martin Spacek (mspacek) wrote :

I'm also experiencing this on the latest 0.92.2 on Xubuntu 16.04. This is actually a new issue for me, I believe after the 0.91 -> 0.92 transition. Exporting the exact same .svg to .pdf in 0.9.2 now causes some of my raster images in the .svg (originally generated as .pdfs by matplotlib in python) to either disappear (when viewed using qpdfview) or to exhibit some kind of fading or blending, especially at the border of the raster image, like some kind of filter has been applied to them. Ungrouping the raster object to the maximum extent, then releasing the mask that is apparently applied to it (by matplotlib?), then deleting the mask, and only *then* exporting to .pdf, seems to solve the problem.

Note that for me this is a regression. Even if matplotlib is doing something strange when generating .pdf files with raster images in them, inkscape used to be able to handle them fine on export, but as of 0.92 no longer does in my experience. Note that everything in the .svg looks and works fine, the issue is only during export to .pdf.

I've attached an example source .pdf, generated by matplotlib. Drag and drop it into a new Inkscape .svg document, and export to .pdf to reveal the issue. Then try the above steps to see it resolved.

Andrew McRae (acmcrae111) wrote :

I'm having the same bug on 0.92.2 for Windows 10. Saving a masked object as a pdf results in a blank pdf.

Matthias (matthiasbock) wrote :

The problem still exists in Inkscape 0.92.2 (5c3e80d, 2017-08-06) on GNU/Linux x86_64 (Debian).

It can be reproduced like so:

# Download a PDF that contains a masked image
curl http://www.cypress.com/file/44791/download -o AN63620.pdf
# Extract the relevant page
pdftk AN63620.pdf cat 3 output pg_0003.pdf
# Use Inkscape to convert the PDF to SVG
inkscape --without-gui "pg_0003.pdf" --export-area-page --export-plain-svg="pg_0003.svg"
# Use Inkscape to convert the SVG back to PDF
inkscape --without-gui "pg_0003.svg" --export-area-page --export-pdf="pg_0003_exported.pdf"
# Observe, that figure 3 is missing on the exported PDF

To post a comment you must log in.