- Home
- Forum
- ASP.NET Core - EJ 2
- Unable to export diagram to SVG images using HTMLtoPdfConverter's ConvertPartialHtmlToSvg() method
Unable to export diagram to SVG images using HTMLtoPdfConverter's ConvertPartialHtmlToSvg() method
Hello Syncfusion team,
My angular app uses Syncfusion's EJ2 diagram control. Since the diagram contains native nodes and custom image nodes, I'm forced to use HTMLtoPDFConvert's Webkit rendering (hosted in an asp.net web API) to print/export the diagram.
I extract the diagram's HTML as a string (using the diagram's GetDiagramContent() method), which I then pass on to my back-end asp.net core webAPI.
However, I'm unable to figure out how to call HTMLtoPdfConverter's ConvertPartialHtmltoSvg() methods, in order to create an SVG image.
What should be the value of the 'htmlElementID' parameter?
|
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
WebKitConverterSettings settings = new WebKitConverterSettings();
settings.WebKitViewPort = new Syncfusion.Drawing.Size(1280,0);
//Set WebKit path
settings.WebKitPath = @"C:\Users\xxxxx\.nuget\packages\syncfusion.htmltopdfconverter.qtwebkit.net.core\19.2.0.44\lib\QtBinariesWindows";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
if (File.Exists("Sample.svg"))
{
File.Delete("Sample.svg");
}
MemoryStream stream = new MemoryStream();
htmlConverter.ConvertToSvg("chart.html", stream);
File.WriteAllBytes("Sample.svg", stream.ToArray()); |
|
MemoryStream stream = new MemoryStream();
File.WriteAllBytes("Sample.svg", stream.ToArray()); |
Hi Gowthamraj,
I'm still a bit confused about the exact process for generating the SVG. Here is what I'm trying to do.
- I have a diagram that looks like this:
- Using the diagram component's getDiagramContent() method, I get the diagram's HTML in string format. This is what it looks like: LINK
- I pass this HTML string to my back-end (asp.net core webAPI).
- Here I'm attempting to call either ConvertToSvg() or ConvertPartialHTMLtoSvg() methods (so that I can convert the HTML string to SVG).
- However, neither of these methods take HTML string as a parameter. They only take a url as a parameter. As a result, I'm unable to figure out how to supply the HTML string to these methods (in order to generate the SVG file).
Thanks,
-Mithun
|
We can convert partial HTML to SVG using HTML element ID, please refer below code snippet and HTML file for more information. But we are facing issue while converting partial HTML to SVG conversion, currently we are analysing on this and we will update further details by July 21, 2021.
|
As we said earlier, currently we are analysing on this and we will update further details by July 22, 2021.
| |
|
I'm still a bit confused about the exact process for generating the SVG. Here is what I'm trying to do.
|
We do not have support for converting HTML string to SVG with HTML to PDF converter. As a workaround you can write the HTML string to file in sample level and then you can convert the HTML file to SVG using ConvertToSvg method.
|
Thanks Sivaram, that worked! I'm now able to export my diagrams to SVG format.
- 6 Replies
- 4 Participants
- Marked answer
-
MI Mithun
- Jul 19, 2021 10:33 AM UTC
- Jul 27, 2021 07:24 AM UTC