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

Free Support Forum - aspose.com

Incorrect position of image when SVG add to PDF

Hello.
I have SVG with some < image> tag. It’s located on the left BOTTOM of the page. I am converting this svg to pdf

    Document doc = new Document();
    Page page = doc.getPages().add();
    page.getPageInfo().setLandscape(true);
    page.getPageInfo().getMargin().setBottom(0);
    page.getPageInfo().getMargin().setTop(0);
    page.getPageInfo().getMargin().setLeft(0);
    page.getPageInfo().getMargin().setRight(0);

    com.aspose.pdf.Image img = new com.aspose.pdf.Image();
    img.setFileType(ImageFileType.Svg);
    img.setImageStream(new ByteArrayInputStream(svg.getBytes()));
    page.getParagraphs().add(img);
    doc.save("output.pdf");

As a result we have an image in the left TOP of the page. All other elements positions are correct. Could you please advise how can we solve this problem?
Also when I have rectungle with gradient color from the top to the bottom in svg in result I get gradient color from the left to the right.

@Anton_Lytvyn,

Kindly send us your source SVG file. We will investigate and share our findings with you. Your response is awaited.

Hello.
There is my SVG file aspose.zip (83.9 KB)
Also svg with gradient color asposeGradient.zip (83.9 KB)

@Anton_Lytvyn,

When we open your SVG files in the Chrome, it shows an error, whereas the Internet Explorer renders an empty page. We request you please review the SVG files and fix the problem, and then share again. We will investigate and share our findings with you.

I used online svg editor for opening and it worked. But I fixed problem and now you can open my SVGs in Chrome or Internet Explorer
aspose.zip (83.9 KB)
asposeGradient.zip (83.9 KB)

@Anton_Lytvyn,

We managed to replicate the said problematic behavior in our environment. We have logged tickets in our bug tracking system as follows:

File name: aspose.svg
PDFJAVA-37273: SVG to PDF - the image is being displaced

File name: asposeGradient.svg
PDFJAVA-37274: SVG to PDF - the gradient color of the shape is changed to the solid color

We have linked your post to these tickets and will keep you informed regarding any available updates.

Hello.
Do you have some information regarding my bugs?
And how I can check status of this bugs if I don’t have access to your jira?

@Anton_Lytvyn,

The linked ticket IDs PDFJAVA-37273 and PDFJ AVA-37274 are pending for the analysis. Our product team will investigate these tickets as per their development schedules. We have linked your post to these tickets and will keep you informed regarding any available updates.

The issues you have found earlier (filed as PDFJAVA-37274) have been fixed in Aspose.PDF for Java 19.6.

The issues you have found earlier (filed as PDFJAVA-37273) have been fixed in Aspose.PDF for Java 20.1.