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

Free Support Forum - aspose.com

Create/Add svg image to a pdf file

Hi


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;

page.Paragraphs.Add(txtFragment);
page.Paragraphs.Add(image);
page.Paragraphs.Add(txtFragment);

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”>450600Highcharts.com";

Image image = new Image(imageString);
image.FileType = ImageFileType.Svg;

Thanks in advance
David

Hi David,


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

https://www.aspose.com/community/forums/834871/create-render-svg-image-and-include-to-pdf/showthread.aspx#834871

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

Best Regards,