用Java实现svg 转换png
String newPath = befores[0]+"before/word.png";
File f=new File(path);
File destFile=new File(newPath);
InputStream in = new FileInputStream(f);
OutputStream out = new FileOutputStream(destFile);
out = new BufferedOutputStream(out);
Transcoder transcoder = new PNGTranscoder();
try {
TranscoderInput input = new TranscoderInput(in);
try {
TranscoderOutput output = new TranscoderOutput(out);
transcoder.transcode(input, output);
} finally {
out.close();
}
} finally {
in.close();
}
问题: 转换格式要求,用href可以正常添加到svg 中,却不能用xlink:href添加到svg中,在转换成png 时必须用到xlink:href,怎么办?
Enclosed Exception:
null:-1
The attribute "xlink:href" of the element <use> is required] with root cause
org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
null:-1
The attribute "xlink:href" of the element <use> is required
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) ~[batik-transcoder-1.6-1.jar:na]
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source) ~[batik-transcoder-1.6-1.jar:na]
求解?