Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 05:33
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/bf76ed5a606a9fdf4e046456c719defb to your computer and use it in GitHub Desktop.
Save aspose-com-gists/bf76ed5a606a9fdf4e046456c719defb to your computer and use it in GitHub Desktop.
Convert HTML to PDF in Linux Programmatically using .NET C#
// 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