TranscoderException while adding svg to pdf using batik -
i trying insert svg content pdf file. using batik same. code follows:
fileinputstream svg = new fileinputstream(new file("my.svg")); transcoder transcoder = new pdftranscoder(); inputstream stream = new bytearrayinputstream(svg.tostring().getbytes()); transcoderinput input = new transcoderinput(stream); transcoderoutput output = new transcoderoutput(filename); transcoder.transcode(input, output); stream.close(); svg.close(); i below error on running above code.
org.apache.batik.transcoder.transcoderexception: null enclosed exception: content not allowed in prolog.
any appreciated.
edit:
here first few lines of my.svg:
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" width="400" height="400"><defs><clippath id="highcharts-4"><rect rx="0" ry="0" fill="none" x="0" y="0" width="9999" height="400" stroke-width="0.000001"/></clippath><clippath id="highcharts-5"><rect fill="none" x="0" y="0" width="380" height="335"/></clippath></defs><rect rx="5" ry="5" fill="#ffffff" x="0" y="0" width="400" height="400" stroke-width="0.000001"/><g class="highcharts-series-group" /><path fill="none" d="m 125.41758851604905 23.732559782274937 c 130.41758851604905 23.732559782274937 133.48045946783446 31.123014540455173 137.69190702653944 41.28488983295301 l 141.90335458524441 51.44676512545085" stroke-width="1" stroke="#fffb76" visibility="visible" transform="translate(10,50)"/><path fill="none" d="m 32.367046022924654 137.13024555199692 c 37.367046022924654 137.13024555199692 45.21323803459761 138.69142168426376 56.001752050647916 140.83803886613063 l 66.79026606669822 142.9846560479975" stroke-width="1" stroke="#fe8e87" visibility="visible" transform="translate(10,50)"/><path fill="none" d="m 55.60634866190446 253.96631493474996 c 60.60634866190446 253.96631493474996 67.25790985518806 249.5214601911162 76.40380649595305 243.40978491861983 l 85.54970313671804 237.29810964612346" stroke-width="1" stroke="#ffc772" visibility="visible" transform="translate(10,50)"/><path fill="none" d="m 338.7608245153441 107.90162787736199 c 333.7608245153441 107.90162787736199 326.370709841463 110.96531929571447 316.2093021648764 115.17789499594912 l 306.04789448828984 119.39047069618377" stroke-width="1" stroke="#2ac6ff" visibility="visible" transform="translate(10,50)"/><path fill="none" d="m 195.0461158567799 323.12499316731794 c 190.0461158567799 323.12499316731794 190.04374524245637 315.12499351855627 190.04048564776022 304.12499400150887 l 190.03722605306407 293.12499448446147" stroke-width="1" stroke="#81cf9b" visibility="visible" transform="translate(10,50)"/><text x="200" y="35" style="font-family:lucida grande;font-size:15px;color:#888888;font-weight:bold;fill:#888888;" text-anchor="middle" class="highcharts-title" ><tspan x="200">chart title</tspan></text><g class="highcharts-shadow" transform="translate(10,50)"><path fill="none" d="m 189.97441355378578 42.375002605636766 125.625 125.625 0 0 1 278.8657401089984 256.7948245106659 l 190 168 0 0 0 0 0 190 168 z" stroke="black" stroke-width="5" stroke-linejoin="round" stroke-opacity="0.049999999999999996" transform="translate(1, 1)"/>
add <?xml version="1.0"?> beginning of file.
also check there's nothing else before <svg...
Comments
Post a Comment