HtmlToPdfConverter::ConvertToImage only creates images in JPEG format?

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.

It looks like the HTMLToPdfConverter::ConvertToImage() method always creates image in JPEG format. I verified this from the return value's Format property.

How do I get the HTMLToPdfConverter::ConvertToImage() method to create images in other formats (like PNG, BMP, SVG etc)?

Please let me know if any additional details are required.


Thanks,

-Mithun






3 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team July 19, 2021 12:07 PM UTC

Hi Mithun, 
 
Thank you for contacting Syncfusion support.  
 
By default, our WebKit HTML converter will generate the images with JPEG format while converting from HTML/URL. We can get PNG format by setting background color to transparent while converting HTML to Image. Please refer below code snippet, 
 
//set transparent color. 
settings.BackgroundColor = Syncfusion.Drawing.Color.Transparent; 
 
 
For converting HTML/URL to SVG format, we have separate method called ConvertToSvg, kindly use this method for converting HTML to SVG format. Please refer below code snippet, 
 
MemoryStream stream = new MemoryStream(); 
 
htmlConverter.ConvertToSvg(chart.html, stream); 
 
File.WriteAllBytes("Sample.svg", stream.ToArray()); 
 
 
Please let us know if you need any further assistance on this.  
 
Regards, 
Gowthamraj K 


Marked as answer

MI Mithun July 19, 2021 02:31 PM UTC

Thanks for confirming Gowthamraj.

I'm able to create PNGs with transparent backgrounds now.

Regarding SVGs, I'll follow up in the other forum thread.


Thanks,

-Mithun




GK Gowthamraj Kumar Syncfusion Team July 20, 2021 05:56 AM UTC

Hi Mithun, 
 
Thank you for your update. We are glad to know that your problem has been solved. 

Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 


Loader.
Up arrow icon