For more details, please visit Convert HTML to PDF File on Linux in .NET
Last active
December 23, 2021 05:33
-
-
Save aspose-com-gists/bf76ed5a606a9fdf4e046456c719defb to your computer and use it in GitHub Desktop.
Convert HTML to PDF in Linux Programmatically using .NET 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
// Set path to a source HTML file | |
string documentPath = "HTMLtoPDF.html"; | |
// Set path for converted file saving | |
string savePath = "HTMLtoPDF.pdf"; | |
// Initialize an HTMLDocument class object | |
HTMLDocument document = new HTMLDocument(documentPath); | |
// Create an instance of the PdfRenderingOptions class | |
PdfRenderingOptions pdfOptions = new PdfRenderingOptions(); | |
// Create the PdfDevice and specify the output file to render | |
PdfDevice device = new PdfDevice(pdfOptions, savePath); | |
// Render HTML to PDF with RenderTo method | |
document.RenderTo(device); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment