load SVG with gradient and export it to PDF

edited August 2014 in Library Questions

hi, i want to load SVGs with gradient (made in illustrator cs6) into my code (which works fine for displaying and even exporting as png, but now i want to export it as PDF with beginRecord(PDF... but it shows only black filled shapes, no gradient will export into the PDF file. i already tried philhos new SVG exporter (import org.philhosoft.p8g.svg.P8gGraphicsSVG;) but it didn't do it either...:( thanks in advance!

Tagged:

Answers

  • Processing handles well SVG gradients, but renders it using a raster, ie. it does a bitmap rendering of the gradient, setting each pixel to the computed color, using AWT primitives to do the job.

    PDF and SVG output expect a vector information instead, information to recreate the gradient, whatever the scale of shape to fill. This information is lost, and these vector renderers doesn't handle well bitmap. So I fear the current state of the code won't allow you to do what you want.

  • How many PNG images are you working with, and how many PDF documents to you want to create from them (e.g. 100 PNGs and 1 PDF, 100 PNGs and 100 PDFs, etc.)?

    If it is a relatively low number, you can always save the SVGs as PNG files through your code and then convert the saved PNGs into one or more PDFs. You can do that using online websites (like this one) or other software.

  • thank you guys and sorry for being so late!

Sign In or Register to comment.