Convert SVG to PDF

Posted by Adrian Smith on Stack Overflow See other posts from Stack Overflow or by Adrian Smith
Published on 2011-07-29T15:56:38Z Indexed on 2012/12/19 5:03 UTC
Read the original article Hit count: 199

Filed under:
|
|

How would one go about converting a SVG file to a PDF programatically? (I need to alter the SVG in certain respects before generating the PDF so simply pre-converting it using a tool won't be sufficient.)

Ideally using Java but Perl or PHP would be fine too.

Obviously I am basically considering Apache FOP and Batik with Java. However no matter how long I search I cannot find a simple introduction on how to do it. Things like SVGConverter have descriptions like "Defines the interface for classes that are able to convert part or all of a GraphicContext", but I don't really know what that means.

I have this feeling there must be an API to do this quite simply, provided by FOP or Batik, but I'm just not able to find it at the moment (or perhaps it really doesn't exist.)

In terms of the supported SVG features I need, the file has some paths which are filled with some linear gradients.

Ideally if I could pass the SVG in as a DOM Document that would be ideal; then I would load my template SVG file, change it as specified by the user, and then generate the PDF.

© Stack Overflow or respective owner

Related posts about java

Related posts about pdf