无法使用 Batik 来将 WMF 转换为 SVG 转换器

问题描述 投票:0回答:1

我必须将 WMF 图像转换为 SVG 图像。

我使用蜡染并得到了这个代码,但它不起作用。运行代码后,会创建一个 SVG 图像文件,但它是完全空的文件。我不知道为什么。请帮助我。

public void converter(String a) throws IOException, TranscoderException
{
    String wmfPath="D:\\locales\\sample.wmf";
    FileOutputStream awmfPath=new FileOutputStream("D:upload\\a6.wmf");
    File wmf=new File(wmfPath);
    FileInputStream wmfStream=new FileInputStream(wmf);
    ByteArrayOutputStream imageOut=new ByteArrayOutputStream();
    byte[]buffer=new byte[1024*1024];
    int noOfByteRead=0;

    while((noOfByteRead = wmfStream.read()) != -1)
    {
            imageOut.write(noOfByteRead);
            awmfPath.write(noOfByteRead);
    }

    imageOut.flush();
    awmfPath.flush();

    WMFTranscoder transcoder = new WMFTranscoder();
    TranscodingHints hints=new TranscodingHints();
    hints.put(WMFTranscoder.KEY_HEIGHT,2000f);
    hints.put(WMFTranscoder.KEY_WIDTH,2000f);
    transcoder.setTranscodingHints(hints);

    TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(imageOut.toByteArray()));
    ByteArrayOutputStream svg = new ByteArrayOutputStream();
    TranscoderOutput output = new TranscoderOutput(svg);

    transcoder.transcode(input, output);
    String svgFile = StringUtils.replace(wmfPath,"wmf","svg");
    FileOutputStream fileOut = new FileOutputStream(svgFile);
    fileOut.write(svg.toByteArray());

    fileOut.flush();
}
svg wmf
1个回答
0
投票

您好,这个问题解决了吗?我也面临类似的错误?转换后的 Svg 字节始终具有路径属性 />

© www.soinside.com 2019 - 2024. All rights reserved.