title: Convert SVG to PDF
body: <p>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.)</p>
  
  <p>Ideally using Java but Perl or PHP would be fine too.</p>
  
  <p>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 <a href="http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/svggen/SVGConverter.html" rel="noreferrer">SVGConverter</a> 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.</p>
  
  <p>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.)</p>
  
  <p>In terms of the supported SVG features I need, the file has some paths which are filled with some linear gradients. </p>
  
  <p>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.</p>