You can read all the details at: Convert SVG Image to HTML Webpage Programmatically in C#
Last active
December 23, 2021 07:11
Convert SVG Image to HTML Webpage Programmatically in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize MemoryStream to save intermediary PDF file | |
MemoryStream stream = new MemoryStream(); | |
// Load input SVG file | |
using (SVGDocument document = new SVGDocument("Sample.svg")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize PdfDevice class object | |
using (PdfDevice device = new PdfDevice(options, stream)) | |
{ | |
// Render SVG to PDF file | |
document.RenderTo(device); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Specify PdfRenderingOptions | |
PdfRenderingOptions options = new PdfRenderingOptions() | |
{ | |
// Set Page Setup properties | |
PageSetup = | |
{ | |
Sizing = SizingType.FitContent | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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