We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SVG is rendered incorrectly in output DOCX/PDF using Java

BPMN.io generates SVGs where some SVG-Path-Elements use a ‘z’ in between.
The SVG-path-content after the ‘z’ starts at the “old” position so the picture is broken (see screenshot below).

When splitting this paths into two separate ones Aspose is able to interpret the SVG well.

Instead of the orginial SVG-Path

             <path d="m 8.459999999999999,11.34 l 0,12.6 l 18.900000000000002,0 l 0,-12.6 z l 9.450000000000001,5.4 l 9.450000000000001,-5.4"
                   style="fill: rgb(250, 250, 250); stroke-width: 1px; stroke: rgb(64, 64, 64);"/>

we now use two SVG-Paths

            <path d="m 8.459999999999999,11.34 l 0,12.6 l 18.900000000000002,0 l 0,-12.6 z"
                  style="fill: rgb(250, 250, 250); stroke-width: 1px; stroke: rgb(64, 64, 64);"/>
            <path d="m 8.459999999999999,11.34 l 9.450000000000001,5.4 l 9.450000000000001,-5.4 z"
                  style="fill: rgb(250, 250, 250); stroke-width: 1px; stroke: rgb(64, 64, 64);"/>

and Aspose 19.8 creates a nice PDF.

The code to insert the SVG to the Document:

public void convertSvgToPdf() throws Exception {

	String pathname = "zInPath.svg";
	final InputStream svgFile = FileUtils.openInputStream(new File(pathname));
	final FileOutputStream fileOutputStream = new FileOutputStream(new File(pathname + ".pdf"));

	Document doc = new Document();
	DocumentBuilder documentBuilder = new DocumentBuilder(doc);
	
	documentBuilder.insertImage(svgFile);

	doc.save(fileOutputStream, new PdfSaveOptions());

	fileOutputStream.close();
	fileOutputStream.close();
}

source SVG.zip (19.3 KB)

@orgavision

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19195. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi,

this is partially solved in Aspose 20.1 or in a previous version greater than 19.8.

svg bpmn tasks.png

This is the used svg svg tasks.zip (1.4 KB)

Can you reproduce this one as well?

Thank you

@orgavision

This issue was solved for the shared SVG file. Please check the attached PDF file. 20.1.zip (1.0 KB)

We have logged this problem in our issue tracking system as WORDSNET-19863 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-19863) have been fixed in this Aspose.Words for .NET 20.5 update and this Aspose.Words for Java 20.5 update.