You can read all the details at: Convert HTML or MHTML to XPS Programmatically in C#
Last active
December 23, 2021 06:20
-
-
Save aspose-com-gists/1c9de9ca4dcb63c8a2d660ef9941fbb6 to your computer and use it in GitHub Desktop.
Convert HTML or MHTML to XPS 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
// Load input HTML file | |
using (HTMLDocument document = new HTMLDocument("test.html")) | |
{ | |
// Initialize XpsSaveOptions | |
Saving.XpsSaveOptions options = new Saving.XpsSaveOptions(); | |
options.BackgroundColor = Color.Gray; | |
options.PageSetup.AnyPage = new Drawing.Page(new Drawing.Size(600, 800), new Drawing.Margin(72, 72, 72, 72)); | |
options.VerticalResolution = 250; | |
// Convert HTML to XPS | |
Converters.Converter.ConvertHTML(document, options, "output.xps"); | |
} |
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 input HTML file | |
HTMLDocument document = new HTMLDocument("test.html"); | |
// Initialize XpsSaveOptions | |
XpsSaveOptions options = new XpsSaveOptions(); | |
// Convert HTML or MHTML to XPS | |
Converter.ConvertHTML(document, options, "output.xps"); |
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 URL for input HTML. | |
Uri uri = new Uri("https://www.aspose.com/"); | |
// Load input HTML with HTMLDocument class. | |
HTMLDocument document = new HTMLDocument(uri.AbsoluteUri); | |
// Initialize XpsSaveOptions class object. | |
XpsSaveOptions options = new XpsSaveOptions(); | |
// Convert HTML from URL to XPS file. | |
Converter.ConvertHTML(document, options, "test.xps"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment