Hi,
In .Net core is it possible to convert HTML to Image DataUrl without saving the image into filesystem.
Basically want data:images/png;base64 value of the image without storing the image in the filesystem.
Any sample code snippet is really appreciate.
Thanks!
Pratheesh
@pratheeshchacko
Thank you for contacting support.
Would you please share the source file while elaborating expected output a little more, so that we may investigate further and help to you.
Hi Farhan,
Thanks for your response.
Below is the code snippet i use.
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-.NET
// The path to the documents directory
string dataDir = RunExamples.GetDataDir_Data();
// Source HTML document
HTMLDocument htmlDocument = new HTMLDocument(dataDir + "input.html");
// Initialize ImageSaveOptions
ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Png);
// Output file path
string outputFile = dataDir + "HTMLtoPNG_Output.png";
// Convert HTML to PNG
Converter.ConvertHTML(htmlDocument, options, outputFile);
The above code snippet create the png image in the local file system, but i dont want my application to create any image file locally introducing IO operations and instead return the base64 format of the image directely from memory.
Let me know if this is something possible using ASPOSE.HTML.
Cheers!
Pratheesh
@pratheeshchacko
We are checking your requirements and will get back to you shortly.
Hi Farhan,
@Farhan.Raza
Do you have any update on this.
Thanks!
Pratheesh
@pratheeshchacko
We would like to update you that Aspose.HTML for .NET provides ICreateStreamProvider interface
which can be used to save the image to memorystream instead to some file path. So you may first save it to memory and then convert image to base64 string as per your requirements.
We hope this will be helpful. Please feel free to contact us if you need any further assistance.