Изображение обрезается при использовании конвертера SVG - PullRequest
0 голосов
/ 26 сентября 2011

Изображение прерывается, когда я пытаюсь преобразовать SVG-файл в PNG-изображение, используя org.apache.batik.apps.rasterizer.SVGConverter.Код Java указан ниже.

SVGConverter svgConverter = new SVGConverter();
svgConverter.setDestinationType(DestinationType.PNG);
svgConverter.setSources(new String[]{ new File(svgsource).toURL().toString() });
svgConverter.setDst(new File(imgDest));
svgConverter.execute();

Также, пожалуйста, найдите код для SVG-файла.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <line x1="10" y1="0" x2="10" y2="500" style="stroke: #000000; stroke-width: 1;" />
 <line x1="10" y1="500" x2="500" y2="500" style="stroke: #000000; stroke-width: 1;" />

<text x="0" y="520"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >3PA</text>
<line x1="100" y1="0" x2="100" y2="500" style="stroke: darkgray; stroke-width: 0.2" />
<text x="100" y="520"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >3PB</text>
<line x1="200" y1="0" x2="200" y2="500" style="stroke: darkgray; stroke-width: 0.2" />
<text x="200" y="520"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >3PC</text>
<line x1="300" y1="0" x2="300" y2="500" style="stroke: darkgray; stroke-width: 0.2" />
<text x="300" y="520"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >4PA</text>
<line x1="400" y1="0" x2="400" y2="500" style="stroke: darkgray; stroke-width: 0.2" />
<text x="400" y="520"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >4PB</text>

<line x1="10" y1="100" x2="500" y2="100" style="stroke: darkgray; stroke-width: 0.2" />
<line x1="10" y1="200" x2="500" y2="200" style="stroke: darkgray; stroke-width: 0.2" />
<line x1="10" y1="300" x2="500" y2="300" style="stroke: darkgray; stroke-width: 0.2" />
<line x1="10" y1="400" x2="500" y2="400" style="stroke: darkgray; stroke-width: 0.2" />


<line x1="10" y1="450" x2="100" y2="450" 
      style="stroke:yellow; stroke-width:5; stroke-linejoin:miter" />


<line x1="100" y1="450" x2="200" y2="330" 
      style="stroke:yellow; stroke-width:5; stroke-linejoin:miter" />


<line x1="200" y1="330" x2="300" y2="380" 
      style="stroke:yellow; stroke-width:5; stroke-linejoin:miter" />



<polygon points="300,380 400,320 400,360 300,380"
    style="fill:paleturquoise; stroke: darkturquoise; stroke-width:1" />


<line x1="100" y1="420" x2="100" y2="460" 
    style="fill:darkturquoise; stroke: darkturquoise; stroke-width:7" />


<line x1="200" y1="340" x2="200" y2="380" 
      style="stroke:darkturquoise; stroke: darkturquoise; stroke-width:7" />

<line x1="300" y1="310" x2="300" y2="350" 
      style="stroke:darkturquoise; stroke: darkturquoise; stroke-width:7" />


<line x1="400" y1="320" x2="400" y2="360" 
      style="stroke:darkturquoise; stroke: darkturquoise; stroke-width:7" />


<text x="400" y="320"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >320</text>
<text x="400" y="360"  style="stroke: none; fill: #000000; font-family: Arial; font-size: 10px;" >360</text>




</svg>

Также найдите изображение онлайн-редактора Online_Editor_image.JPG и png файл, который генерируется кодом Java enter image description here.

Пожалуйста, помогите мне получить полное изображение в качестве онлайн-редактора изображений.

1 Ответ

0 голосов
/ 26 сентября 2011

Укажите высоту и ширину в теге svg как

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="600" height="600">

...