Burak
Burak

Reputation: 507

IText7 - IText7 is Not Properly Drawing SVG Documents

Project Information : .NETCore v3.1 - IText7 v7.1.11

We have a PDF Document builder library created by IText7 nuget package, where we can dynamically building large PDF files for our customers.

Normally we are working with .jpg format but a new feature is added to our online side which is we have started to work with also interactive SVG files with hotspots integrated to our UI.

So, when our application builds a PDF Document it also needs to import those SVG files, we can use it by:

var image = SvgConverter.ConvertToImage(
                    new FileStream(imagePath, FileMode.Open, FileAccess.Read), pdfDocument);

The Original File (I can't upload a SVG so I am uploading as jpg but this is not important because I just want to show the line thickness):

Input

Output is shown below, as you can see on the left side the lines become very thick and parts are not shown as expected.

Output

Steps:

I have tried them all but results are same for all.

Questions:

Thank you for your time!

Upvotes: 0

Views: 595

Answers (1)

Alexey Subach
Alexey Subach

Reputation: 12312

When you invoke SvgConverter.ConvertToImage or SvgConverter.ConvertToXObject, your SVG is not converted into a raster image - it still remains a vector image. So you can use the integrated SVG converter workflow and you are in fact using it with the SvgConverter. The converter is needed to process SVG file format into more PDF-specific structures, so it performs some conversion because PDF does not support SVG directly. This is not vector -> raster conversion though.

Regarding the problem with the line thickness, first think you should do is to try with the latest version - as far as I see you are trying with 7.1.11 while it's dated back to around a year and 7.1.15 is out already. If the problem persists then it's a bug in the SVG support in iText and you can try to minimize the SVG file to see if there is a workaround to achieve proper conversion until the bug is fixed for your case and/or report the problem to iText (StackOverflow is not the right place to report bugs).

Upvotes: 1

Related Questions