**瑱 2021-08-30 02:42 采纳率: 55%
浏览 168
已结题

将svg 转换成png/jpg格式出线xlink:href

用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]

求解?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 9月7日
    • 创建了问题 8月30日

    悬赏问题

    • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
    • ¥15 气象网格数据与卫星轨道数据如何匹配
    • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
    • ¥15 微软账户问题不小心注销了好像
    • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
    • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
    • ¥20 关于web前端如何播放二次加密m3u8视频的问题
    • ¥15 使用百度地图api 位置函数报错?
    • ¥15 metamask如何添加TRON自定义网络
    • ¥66 关于川崎机器人调速问题