提上 batik 库的官网
Apache(tm) Batik SVG Toolkit - a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) http://xmlgraphics.apache.org/batik/
强大个 batik 库本身 就能读取、创建 svg,同时 可以转为 png jpeg。。。
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.fop.svg.PDFTranscoder;
public class SVGToPDF {
public static void main(String[] args) {
String input = "f:/a/1.svg";
String out = "f:/a/1.pdf";
try {
long start = System.currentTimeMillis();
TranscoderInput transcoderInput = new TranscoderInput(
new FileInputStream(new File(input)));
TranscoderOutput transcoderOutput = new TranscoderOutput(
new FileOutputStream(new File(out)));
Transcoder transcoder = new PDFTranscoder();
transcoder.transcode(transcoderInput, transcoderOutput);
long end = System.currentTimeMillis();
System.out.println(end-start);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TranscoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}