Masks don't work on print or PDF

Bug #208217 reported by Rygle
48
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
High
Rygle
inkscape (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When printing on 0.46 branch, objects with masks don't appear on the print.

In the attached picture, the turtle sitting in the water has a mask with a gradient to make his feet fade into the water. He prints fine in 0.45.1, but in 0.46 branch he's gone.

Exporting to bitmap works fine on 0.46. Printing to bitmap (Render as bitmap) works fine also on 0.46. Save as PDF via cairo keeps the turtle but loses all blurs (blurs not implemented in PDF) and the mask, so his legs are fully visible. I think PDF should be capable of a blend to transparent, because the leaves on the bushes blend to transparent and they export to pdf beautifully.

Revision history for this message
Rygle (rygle) wrote :
Revision history for this message
Rygle (rygle) wrote :

Here's how the PDF comes out.

Revision history for this message
Rygle (rygle) wrote :

Here's a screenshot of the .ps file as displayed in Ghostview. Not both blur misalignment and mask problems.

Revision history for this message
Ulferikson (ulferikson) wrote :

Rygle,

Printing could be a Windows specific issue, but as long as you find similar problems with the Ps and Pdf output it is more likely a general issue. (and since 0.45 only had print as bitmap on Windows it is no regression either)

Problem is probably that Inkscape doesn't translate blur/masks/clips correctly to cairo operators.

Currently there are two svg to cairo converters in Inkscape. I think the plan is to only have one in 0.47.

Save as "PDF via Cairo" uses the old printer backend (sp_item_invoke_print). While both printing as vectors and Save as "Postscript via Cairo" uses the newer CairoRenderer class which should be a little more capable. The printer backend doesn't support clips and masks for instance. See: https://bugs.launchpad.net/inkscape/+bug/169755

If you open extension/init.cpp and search for CairoRendererPdfOutput and CairoRendererOutput you can activate Save as "Cairo PDF experimental" and "Cairo PNG" which both use the CairoRenderer class. When the Png looks okay but the Pdf or Ps doesn't you might have found a cairo issue, otherwise it is more likely an Inkscape issue.

Can you find a very simple example to show when clipping/masking works and when it doesn't?

Revision history for this message
Rygle (rygle) wrote :

Don't know if this would be counted as critical enough for 0.46.1, but it's a pretty important feature that should be fixed for 0.47.

Changed in inkscape:
assignee: nobody → pittos
importance: Undecided → High
milestone: none → 0.47
status: New → Confirmed
Revision history for this message
Rygle (rygle) wrote :

Thanks Ulf for the pointers.

I can't find a reference to experimental PDF code in src/extensions/init.cpp - It seems that the normal pdf output routine is in src/extension/internal/cairo-pdf-out.cpp, and the experimental code is in src/extension/internal/cairo-renderer-pdf-out.cpp

Also found a whole lot of stuff that's not used in src/extension/internal/cairo-pdf.cpp - like switches to change between bitmap and vector for pdf's

If anyone does know how to activate the experimental PDF code, or take this any further, that would be great.

Revision history for this message
Rygle (rygle) wrote :

Tested creation scene on Ubuntu Hardy (8.04) with 0.46.

Printing to either PDF or PS loses the masked object altogether.
Saving to either PDF or PS via Cairo keeps the masked object, but loses the mask.
Save as png works fine.

Need to chase up the experimental PDF output.

Revision history for this message
Ulferikson (ulferikson) wrote :

> I can't find a reference to experimental PDF code in
> src/extensions/init.cpp

I never said you would :)

" If you open extension/init.cpp and search for
" CairoRendererPdfOutput and CairoRendererOutput you
" can activate Save as "Cairo PDF experimental"
" and "Cairo PNG"

Simply change the "if (0)" into "if (1)" and recompile. That should activate the two extra export formats.

Again, I think you should search for a much simpler example. Try a drawing with only two or three objects. When does clipping/masking work and when doesn't it? Post both input svg and output pdf (don't bother with ps or printing yet). Only then can you hope for Adrian to tell whether Inkscape or Cairo is wrong :-)

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Another example of bad rendering with "Save Copy As" PDF and Cairo PNG for the attached svg

Revision history for this message
Yann Papouin (yann-papouin) wrote :

PDF rendering of the svg

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Cairo PNG rendering of the svg (different result from PDF and inskcape rendering)

Revision history for this message
Yann Papouin (yann-papouin) wrote :

I forgot to give you my Inkscape version :

Inkscape 0.46+devel, built Sep 3 2008 on Win32

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

I just checked in some fixes to clipping and masking. Try now with SVN.

I quickly checked Creation Scene Colour A4.svg saved as PDF. It looks OK to me in Acroread but not Evince. This is certainly an Evince bug.

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

tried it on svn 19851, plain masked objects are now exporting ok to pdf, BUT, if the object under the masc has a blur, the blur is not rendering at all.
On the creation A4 file, i get the gradient on the tutrles feet, but all the rest (sky, sun, grass) show's all messed up (using evince).
Sky & co looking ok with acroread but a big blurry black spot appears on the grass.
Inkscape can't open anymore the pdf it creates.

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

Just checked in a fix for things rendered as bitmaps (i.e. filters) which should fix objects with blurs that have transformations attached (like the grass).

I don't think we can do much about the evince problems other than file bug reports with them.

Inkscape not being able to open pdf files should probably be filed under a new/different bug.

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

svn 19864, yep everything rendering ok now for the creation file now in acroread. thanks tavmjong... BUT... still getting some weird rendering on other files (see attachement)

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

pdf export

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Your test2.svg is rendered like the pdf in Firefox3, that's a Firefox bug too ?

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

i didn't see the cutting on the side apperaing in firefox you're right, but the rest of the rendering problem shows only on pdf.
here is my view of:
acroread-evince
inkscape-firefox

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

"Layer1" is translated... this should be legal but I don't know how that happens in normal Inkscape use.
It looks like the cutting edge on the right corresponds to the edge of the canvas if the layer was not shifted.

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

A little more inspection shows that the bottom and right cut offs are due to the translation to "Layer1" (cut offs are at page boundary before translation) while the top cut off is due to a mask being applied over a blurred object (cut off is at bounding box of masked object prior to blurring).

The attached file demonstrates the latter problem more clearly. The dashed line shows the bounding box of the masked object before blurring.

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

not sure i understood fully your explanation, but by grouping the object and the blur before masking (as to changing boundary) the top cut off disapears on both acroread and evince renders, right cut off is still present in acro/evince but disappears in firefox render, bottom cut off prensent in all.

I didnt notice before but when the "red circle" and blur are not grouped, when applying mask inkscape duplicates the mask (square with gradient), to mask them spearately, which leads to the top cut off.

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote : Re: [Bug 208217] Re: Masks don't work on print or PDF

je viens de remarquer le "free.fr".. peut être qu'en français je
comprendrais mieux ton explication.. qu'est-ce que tu entends par
"translation to layer 1"

On Thu, 2008-09-18 at 09:17 +0000, Tavmjong Bah wrote:
> A little more inspection shows that the bottom and right cut offs are due to the translation to "Layer1" (cut offs are at page boundary before translation) while the top cut off is due to a mask being applied over a blurred object (cut off is at bounding box of masked object prior to blurring).
>
> The attached file demonstrates the latter problem more clearly. The
> dashed line shows the bounding box of the masked object before blurring.
>
>
> ** Attachment added: "SVG file with mask over blurred object."
> http://launchpadlibrarian.net/17716678/mask_over_blur_test.svg
>

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

Bonjour,

Oui, j'habite en France mais, malheureusement, je ne parle pas français très bon… J'essayerai d'expliquer encore en anglais.

"Layer 1" is an Inkscape term which in French is "Calque 1"... see:

http://tavmjong.free.fr/INKSCAPE/MANUAL/html_fr/Layers.html

It is really just a group, so it can be translated (déplacement). If you remove the translation using the XML editor... see:

http://tavmjong.free.fr/INKSCAPE/MANUAL/html_fr/XML.html

one finds that the circle before translation is partially off the page. The part that is off the page is missing along the right side and bottom.

Revision history for this message
Tavmjong Bah (tavmjong-free) wrote :

I just checked in a fix for the problem along the top of the edge. In the code for masking, a clipping with the geometric bounding box of the mask was being applied. This doesn't allow for cases where a filter draws outside the geometric bounding box. I removed the clipping.

The problem with the other edges is more complicated. A masked object overlapping the edge of the page and then translated onto the page will be drawn in the PDF file correctly. However, if the masked object is first placed in a group (a layer is actually a group) and then translated, the part initially drawn off the page will be missing.

The attached file demonstrates this problem more clearly. The circle was first drawn with its center at the lower right corner of the page. The circle was then partially masked by a rectangle. This was then placed inside a group and the group translated so that the center if the circle is at the center of the page.

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

i don't know it this belongs to this bug or should be marked as a different bug.

when you export a pdf, and select the option "rasterise filter effects", the quality of the rasterised effect is linked the quality of display of filter effects/gaussian blur in the inkscape preferences.

As i understand this option should be only for the display inside inkscape, and the pdf should be exported to the maximum quality.
But if (for ex.) your "Filter effects quality for display" in the preferences is set to Average, or lower ... this becomes the quality of output of the rasterised effect in the pdf.

is it a bug or did i miss something?

(btw... i'm using inkscape svn 20346 on ubuntu 8.10)

Revision history for this message
theAdib (theadib) wrote :

RIco, the current svn version has in the export dialog the option "prefered resolution for filter effects". This should solve your problem. If it does not change the bitmap quality pls file a bug. HTH, Adib.

Revision history for this message
RIco (rico-rootscore-deactivatedaccount) wrote :

that doesn't change the bitmap quality, bug already filed (322116)

Rygle (rygle)
Changed in inkscape:
status: Confirmed → Fix Committed
Revision history for this message
theAdib (theadib) wrote :

Rico,
I found that the image quality is affected by the filter-display-quality option in the inkscape preferences.
See this bug https://bugs.launchpad.net/inkscape/+bug/322116
Adib.

Rygle, what is the status of this bug?

Revision history for this message
jacob corvidae (jacob-warmtraining) wrote :

Hi Folks,

I don't know if this'll help with the bug discussion -- I'm a user, not a developer, but just found this bug report while researching whether I should submit a new bug for this issue.

I've got an SVG file with masks and am having the problem outlined originally above, but another problem as well, which I thought might help shed some additional light. The original problem stands: I save as PDF or EPS and the file comes through without the masks in place. Here's the new/other related problem: When I just print directly from the SVG to my paper printer or to CutePDF, the masked objects simply don't appear at all. I'll send sample files next.

Revision history for this message
jacob corvidae (jacob-warmtraining) wrote :

The original svg file.

ScislaC (scislac)
Changed in inkscape:
status: Fix Committed → Fix Released
Revision history for this message
roothorick (8-roothorick-gmail-com) wrote :

Don't think it's fixed. I'm having the same problem with 0.47 (release). I made a simple testcase SVG of a red square with a mask of a square with a white-to-transparency gradient fill, on top of a blue square, resulting in a red-blue gradient.

export as PNG -> expected results (red-blue gradient)
save a copy, PDF -> solid blue square (masked object removed entirely)
Print -> solid blue square (masked object removed entirely)

Clearly, this isn't fixed yet.

Interestingly, Uniconvertor also gets it wrong (solid red square, discarding the mask).

This is inconsistent with the problem I originally had that led me to this bug (gradient-masked object not getting the gradient fade, instead being cut off at seemingly arbitrary locations that have zero relation to the bounding box or contents of the mask). I tried to make a testcase for that, but can't seem to narrow down that specific behavior.

Revision history for this message
seamus1089 (s-holden1) wrote :

I still experience this bug with 0.48 r9654 - masking fails on pdf export.

Ubuntu 10.04 64bit. Cairo 1.8.10
Test case svg and pdf of a masked rectangle are attached. Clipping of the same object works without problems.

Thanks

Revision history for this message
su_v (suv-lp) wrote :

@seamus1089 - see bug #597974 (fixed in trunk and for 0.48.1)
<https://bugs.launchpad.net/inkscape/+bug/597974>

Revision history for this message
su_v (suv-lp) wrote :

@Ben A - after redoing the masking in your example in a new layer (without 'transform' attribute due to page resize), export and rendering in other SVG viewers is the same as in Inkscape.

See bug #404009: "The problem happens when you do a "Fit page to selection" on the object. Which implies that inkscape is treating the transformations on the mask differently than in Firefox, opera and Baltik"
<https://bugs.launchpad.net/inkscape/+bug/404009>

Revision history for this message
Jonathan Allard (joallard) wrote :

I still get the bug in Inkscape 0.48.3.1/libcairo2 1.10.2.

Masked paths are rendered bitmap when exporting to PDF, but not PNG. The mask works as expected, except the output of it is bitmap. Non-masked shapes are rendered correctly.

Revision history for this message
quazgar (quazgar) wrote :

The bug is back again in 0.91, the turtle from the original image is hidden.

Revision history for this message
Alex Valavanis (valavanisalex) wrote :

Reopening after comment #37

Changed in inkscape (Ubuntu):
status: New → Fix Released
status: Fix Released → New
Changed in inkscape:
status: Fix Released → New
Revision history for this message
su_v (suv-lp) wrote :

Proposing to revert the bug status changes and close this old report again - the elements which are missing in the PDF file if exported with more recent cairo versions are curved paths with very very thin (almost invisible) stroke widths.

The cairo issue is tracked for Inkscape in
* Bug #1174909 “inkscape fails to print thin lines to PDF”
  https://bugs.launchpad.net/inkscape/+bug/1174909
and is not related to the issue originally tracked in this report (bug #208217).

jazzynico (jazzynico)
Changed in inkscape:
status: New → Fix Released
Changed in inkscape (Ubuntu):
status: New → Fix Released
Revision history for this message
hanan (hanin) wrote :

I think this bug is back again in Inkscape 0.92+ (Fedora 26 but not exist in inkscape flatpak), and when I tried to set a mask by a rectangle full with gradient from white to black, the shape disappeared, when I released the mask again the rectangle turned to black without gradient. I tried this process again but I inverted the gradient (Black is up and white is down) and the after (mask- set) step, the shape still itself without any transparency, when I released the mask the rectangle turned to completely white this time. so I think the bug is that the mask set by one color from the gradient, almost it is the second color as I noticed.

Revision history for this message
Andrew McRae (acmcrae111) wrote :

Not sure whether it is this one, or Bug #427540, but I am having this issue for 0.92.2 in Windows 10. An svg with a mask saved as a PDF shows a blank pdf output. Also, if I look at the SVG file in a browser (chrome, or IE), the masked item does not show up. The masked item is visible in the inkscape viewer however.

Revision history for this message
Dirk Lucas (aospades) wrote :

Same here. I have a masked jpg in an image, it will neither print as a pdf nor will it be printed on a physical colour printer. Inkscape 1.0.1 (3bc2e813f5, 2020-09-07)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.