PDF import problem with radial gradients and clip path

Bug #919176 reported by Adrien Cordonnier on 2012-01-20
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Medium
Alvin Penner

Bug Description

Tested with Inkscape 0.48.1, Windows 7 Professional 64 bits.

According to the following examples, the radial gradients (<svg:radialGradient>) are not imported correctly (not rendered) when combined with a clip path (<svg:clipPath>). Ungrouping all the groups of the PDF may eventually recover the radial gradients.

1. Importation fails for the radial gradients of the following PDF file:

http://www.soletanche-bachy.com/SBF/sbf.nsf/technique/ouvrages-maritimes-/$File/OuvragesMaritimes2010Vf.pdf
Import page 1, the radial gradient from the logo is not rendered.
Open the XML Editor (Shift+Ctrl+X)
Ungroup all groups one by one (Shift+Ctrl+G).
After you have ungrouped elements from the logo, you can notice with the gradient tool that they indeed have a radial gradient associated but the gradient is located far on the right.

2. Importation succeeds for the radial gradient of the following PDF file:

http://www.cnrs.fr/aquitaine-limousin/IMG/pdf/CHARTECNRS2010-1.pdf
Import page 1, the radial gradient from the logo has been correctly imported.

3. Two files with the same logo, one correctly imported, the other not:

http://www.egis.fr/content/download/1087514/15760665/file/EgisEssentiel2011_FR_BD.pdf
Import page 1, the radial gradient from the red logo (grey circle) has been correctly imported.

http://www.egis-rail.fr/content/download/1129027/16303376/file/FR_plaquette%20ferroviaire.pdf
Import page 7 (last page), the radial gradient from the red logo (grey circle) is not rendered.
Open the XML Editor (Shift+Ctrl+X)
Ungroup all groups one by one (Shift+Ctrl+G). It may take several minutes.
As you ungroup, you will see grey objects with radial gradient appearing. The radial gradients are correctly located
The grey circle is in group "g702".

description: updated
su_v (suv-lp) wrote :

Possibly addressed by the fix in r10680 for
Bug #530895 in Inkscape: “Opening EPS with Gradient”
<https://bugs.launchpad.net/inkscape/+bug/530895>
(see comment #4 there)

tags: added: gradient importing pdf
su_v (suv-lp) wrote :

> Tested with Inkscape 0.48.1, Windows 7 Professional 64 bits.

Please also test with current stable (0.48.2).

su_v (suv-lp) wrote :

Displaced gradients in
- OuvragesMaritimes2010Vf.pdf
- FR_plaquette%20ferroviaire.pdf
reproduced with Inkscape 0.48.2 on OS X Lion (poppler 0.18.2, cairo 1.10.2)

Testing with Inkscape 0.48+devel r10911 on OS X Lion:
- OuvragesMaritimes2010Vf.pdf
gradient is positioned correctly, but scales slightly different than displayed in the PDF file
- FR_plaquette%20ferroviaire.pdf
gradient of clipped path(s) is not visible.

su_v (suv-lp) wrote :

Seems partially fixed in current trunk.

Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
su_v (suv-lp) wrote :

Displaced gradients in
- OuvragesMaritimes2010Vf.pdf
- FR_plaquette%20ferroviaire.pdf
are imported and rendered correctly with the experimental input file format "Adobe PDF via poppler-cairo (*.pdf)" in current trunk.
(See also <http://inkscape.13.n6.nabble.com/pdf-import-again-poppler-native-vs-poppler-cairo-tt2812859.html>)

Alvin Penner (apenner) wrote :

it appears that there are two (or more) separate bugs shown here.

a partial fix for one has been committed to bzr rev 11094.
this will properly display the gradient in the logo at the bottom right hand corner of page 7 of FR_plaquette ferroviaire.pdf. It also makes visible a long curved horizontal line just above the logo. There is still a problem with a rounded rectangle at the bottom left, which is not displayed completely.

Alvin Penner (apenner) wrote :

a better fix for one bug has been committed to bzr rev 11112.
 this will properly display the rounded rectangle at the bottom left corner of page 7 of FR_plaquette ferroviaire.pdf. The previous fix was assuming that there were no rotations when a bounding box gets transformed, the current fix allows for the possibility of rotations or skewing.

Alvin Penner (apenner) wrote :

in the file OuvragesMaritimes2010Vf.pdf, the radial gradient in the logo at the bottom right of page 1 is getting corrupted during the operation saveState() in the file pdfparser.cpp.

Before the saveState operation the parameters are (cx, cy, fx, fy, r) = (0, 0, 0, 0, 1) (these are typical of most radial gradients)
After the saveState operation the parameters are (cx, cy, fx, fy, r) = (0, 1, 0, 0, 1) (this change should not have occurred)

this is causing the observed distortion in the gradient. This appears to be a Poppler bug. In any event, I do not know how to fix it, so the workaround is to not refresh the state. A more elegant solution would be welcomed.

change committed to rev 11184

Alvin Penner (apenner) wrote :

in the file OuvragesMaritimes2010Vf.pdf there is a remaining problem with the logo at the bottom right on page 1, namely the bright spot is too large. imho, this cannot be solved because it uses a feature not supported in Inkscape.

Using the Python package 'pdfminer 2011', this pdf file was parsed. It was found that this radial gradient uses a FunctionType = 2, which is a non-linear relationship between color and screen position, not supported by Inkscape, or svg as far as I can tell. The function is exponential, and is defined in section 7.10.3 in the document PDF32000_2008.pdf by Adobe.

I believe this addresses all the issues encountered in these pdf files, unfortunately not always successfully.

Alvin Penner (apenner) wrote :

in the file OuvragesMaritimes2010Vf.pdf, the size of the bright spot at the bottom right on page 1 has been adjusted by implementing a very approximate version of an ExponentialFunction. By evaluating the slope of the exponential function at x = 1 and using this in a linear gradient, and by adding an extra stop, the bright spot now looks similar to the original pdf file.

committed to rev 11256

Changed in inkscape:
status: Confirmed → Fix Committed
su_v (suv-lp) on 2012-04-15
Changed in inkscape:
assignee: nobody → Alvin Penner (apenner)
milestone: none → 0.49
Alvin Penner (apenner) wrote :

an improved workaround for the problem with the saveState operation in comment 8 above, has been committed to rev 11340.
This new version does not have the unexpected side effects that were seen in Bug 985182.

Alysko (w-contact+launchpad) wrote :

It didn't work in 0.48 stabke but IT WORKS NOW with 0.48+r12340 : all my PDF import with multiple and different gradients works fine :)

Bryce Harrington (bryce) on 2015-02-21
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers