About <radialGradient> and export PNG / PDF

Post questions on how to use or achieve an effect in Inkscape.
aypierre

About <radialGradient> and export PNG / PDF

Postby aypierre » Thu Dec 02, 2010 8:18 pm

Hi,

I'm using a radialGradient in my svg :

<text xml:space="preserve" text-anchor="right" font-family="Guia Script" font-size="20" y="24.4666" x="275.666" stroke-width="0" stroke="#000000" fill="url(#svg_5)" id="svg_4">............</text>

[...]

<defs>
<radialGradient id="svg_5" cx="0.988281" cy="0.5" r="0.5" fx="0.988281" fy="0.5">
<stop offset="0" stop-color="#000000"/>
<stop offset="1" stop-color="#e5e5e5"/>
</radialGradient>
</defs>


Now, something weird happened when I'm exporting my svg from inkscape (I'm using inkscape in command-line from a .net application)
The gradient render is ok in inkscape, it's ok in the PNG, but not in the PDF, where there is no gradient at all applied :

Here you can see the render in SVG - PNG - PDF and see what the problem is :
Image

The only "solution" I find is to trick the system by exporting my SVG in PNG and then creating a PDF with the PNG using iText, but that's not very clean...

Is there any other solution ?

Thx

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: About <radialGradient> and export PNG / PDF

Postby brynn » Fri Dec 03, 2010 5:41 am

To my knowledge, it should be possible to convert SVG with gradient to PDF without loss, since version 0.47. However, I know next to nothing about command line usage. What version are you using?

Here is a reply to my similar question in another topic recently:
~suv wrote:
brynn wrote:It's been my understanding that SVG images cannot be converted to PDF using Inkscape, without losing gradients, filters or blurs that might be used in the image.
Have you actually tried saving a copy as "Portable Document Format (*.pdf)" with a current version of Inkscape? All those types are supported since Inkscape 0.47 and converted to PDF, keeping the appearance as close as possible to how the SVG file renders on canvas. The PDF file format supports transparency and gradients for vector objects; blurred objects and those with other SVG filter effects applied are converted to bitmap during the export (you can set the dpi resolution in the export options dialog).


In the end, I was successful in converting SVG with blurs to PDF. But my test did not include gradients. I wonder if there might be particular selections which should be chosen in the conversion dialog. Although again, I'm not sure with the command line.

Sorry, I wish I could be more helpful, but I'm sure other will be along who know more about it :D

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: About <radialGradient> and export PNG / PDF

Postby ~suv » Fri Dec 03, 2010 8:01 am

aypierre wrote:Is there any other solution ?
I can reproduce the issue when using your code sample and exporting to PDF. However if I redo the gradient in Inkscape (copying the text object, and defining a new (opaque) gradient for the fill), the PDF exports as expected and looks identically to what is rendered on-canvas in Inkscape (tested with Inkscape 0.48.0 and 0.48+devel r9913, cairo 1.8.10 and 1.10, on Mac OS X 10.5.8).

Inkscape uses two types of gradient definitions: one to define the gradient itself (the stops and their color) and one to define the geometry / position related to the object the gradient is applied to. Maybe it would help you to closer inspect how Inkscape does it and try to reproduce this structure with your external tool that creates the SVG file (a guess -- because the code snipped you provided is not produced by Inkscape as far as I can tell).

aypierre

Re: About <radialGradient> and export PNG / PDF

Postby aypierre » Fri Dec 03, 2010 9:01 pm

~suv wrote:
aypierre wrote:Is there any other solution ?
I can reproduce the issue when using your code sample and exporting to PDF. However if I redo the gradient in Inkscape (copying the text object, and defining a new (opaque) gradient for the fill), the PDF exports as expected and looks identically to what is rendered on-canvas in Inkscape (tested with Inkscape 0.48.0 and 0.48+devel r9913, cairo 1.8.10 and 1.10, on Mac OS X 10.5.8).

Inkscape uses two types of gradient definitions: one to define the gradient itself (the stops and their color) and one to define the geometry / position related to the object the gradient is applied to. Maybe it would help you to closer inspect how Inkscape does it and try to reproduce this structure with your external tool that creates the SVG file (a guess -- because the code snipped you provided is not produced by Inkscape as far as I can tell).



Ok, I'll try that. Currently the gradient is build in the google web editor "svg-edit", that's reason it's different from what inkscape do, I never thought about that. Thx

@to brynn : I'm using 0.47


Return to “Help with using Inkscape”