Guest User

Untitled

a guest
Oct 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Save this SVG into a file (required by SVG -> PDF transformation process)
  2. File svgFile = File.createTempFile("graphic-", ".svg");
  3. Transformer transformer = TransformerFactory.newInstance().newTransformer();
  4. DOMSource source2 = new DOMSource(svgXmlDoc);
  5. FileOutputStream fOut = new FileOutputStream(svgFile);
  6. try { transformer.transform(source2, new StreamResult(fOut)); }
  7. finally { fOut.close(); }
  8.  
  9. // Convert the SVG into PDF
  10. File outputFile = File.createTempFile("result-", ".pdf");
  11. SVGConverter converter = new SVGConverter();
  12. converter.setDestinationType(DestinationType.PDF);
  13. converter.setSources(new String[] { svgFile.toString() });
  14. converter.setDst(outputFile);
  15. converter.execute();
Add Comment
Please, Sign In to add comment