Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/eb87f65e510ed15561ec27b7eef7dbcb to your computer and use it in GitHub Desktop.
Save aspose-com-gists/eb87f65e510ed15561ec27b7eef7dbcb to your computer and use it in GitHub Desktop.
Convert SVG Image to HTML Webpage Programmatically in C#
// Initialize MemoryStream to save intermediary PDF file
MemoryStream stream = new MemoryStream();
// Load input SVG file
using (SVGDocument document = new SVGDocument("Sample.svg"))
{
// Specify PdfRenderingOptions
PdfRenderingOptions options = new PdfRenderingOptions()
{
// Set Page Setup properties
PageSetup =
{
Sizing = SizingType.FitContent
}
};
using (PdfDevice device = new PdfDevice(options, stream))
{
// Render SVG to PDF file
document.RenderTo(device);
}
}
// Load the PDF document
Document pdfDocument = new Document(stream);
// Save SVG file contents to output HTML format
pdfDocument.Save("Sample.html", SaveFormat.Html);
// Initialize MemoryStream to save intermediary PDF file
MemoryStream stream = new MemoryStream();
// Load input SVG file
using (SVGDocument document = new SVGDocument("Sample.svg"))
// Initialize PdfDevice class object
using (PdfDevice device = new PdfDevice(options, stream))
{
// Render SVG to PDF file
document.RenderTo(device);
}
// Specify PdfRenderingOptions
PdfRenderingOptions options = new PdfRenderingOptions()
{
// Set Page Setup properties
PageSetup =
{
Sizing = SizingType.FitContent
}
};
// Load the rendered PDF document
Document pdfDocument = new Document(stream);
// Save SVG file contents to output HTML format
pdfDocument.Save("Sample.html", SaveFormat.Html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment