Create/Add svg image to a pdf file


I’m trying to include a svg image to a pdf Page. That works fine if i have the svg file saved on my server (Example below).

string chartDir = “C:\Temp\”;

Document doc = new Document();

Page page = doc.Pages.Add();

TextFragment txtFragment = new TextFragment(“Lorem ipsum…”);

txtFragment.Margin = new MarginInfo(10, 20, 10, 20);

txtFragment.TextState.ForegroundColor = Color.BlueViolet;

txtFragment.TextState.FontSize = 20;

txtFragment.TextState.FontStyle = FontStyles.Bold;

txtFragment.TextState.FontStyle = FontStyles.Italic;

Image image = new Image();

image.File = chartDir + “chart.svg”;

image.FileType = ImageFileType.Svg;




return doc;

Well, I have a service which returns the svg content as a string. Is there a way to create and add the image to the pdf without saving a svg file on the server?

Something like:

string imageString =“<?xml version="1.0" standalone="no"?>Created with Highstock 5.0.10<clip…nslate(0,0)” y=“120” opacity=“1”>";

Image image = new Image(imageString);

image.FileType = ImageFileType.Svg;

Thanks in advance


Hi David,

Please check following post for the reply, you have been responded there.

If you still face any issue or need further assistance, please feel free to contact us.

Best Regards,