Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Use the HTML Converter guides when your source is an HTML file, HTML string, stream, or URL. Aspose.HTML for .NET lets C# applications convert HTML to PDF, XPS, DOCX, JPG, PNG, BMP, TIFF, GIF, MHTML, and Markdown.
HTML conversion is the central workflow in Aspose.HTML for .NET because HTML is often the source format for reports, invoices, web pages, archives, and generated content. Most examples in this section use HTMLDocument, a target-specific save options class, and Converter.ConvertHTML().
HTMLDocument or a ConvertHTML() overload.PdfSaveOptions, ImageSaveOptions, DocSaveOptions, XpsSaveOptions, MHTMLSaveOptions, or MarkdownSaveOptions.Converter.ConvertHTML() and pass the source, options, and output path or stream provider.The following example converts an HTML file to PNG with ImageSaveOptions.
1// Convert HTML to PNG in C#
2
3// Prepare a path to a source HTML file
4string documentPath = Path.Combine(DataDir, "nature.html");
5
6// Prepare a path to save the converted file
7string savePath = Path.Combine(OutputDir, "nature-output.png");
8
9// Initialize an HTML document from the file
10using HTMLDocument document = new HTMLDocument(documentPath);
11
12// Create an instance of the ImageSaveOptions class
13ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Png);
14
15// Convert HTML to PNG
16Converter.ConvertHTML(document, options, savePath);For conversion parameters, output streams, and page setup, open the format-specific guides below.
HTML to fixed-layout documents
PdfSaveOptions.XpsSaveOptions.HTML to Word and web archive formats
DocSaveOptions.HTML to image formats
Use the online HTML Converter for quick file checks. Use Aspose.HTML for .NET when HTML conversion must be automated in C# code.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.