Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created June 10, 2022 13:08
Show Gist options
  • Save aspose-com-gists/7588fbdd00f173796beaeb57e69cbb58 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/7588fbdd00f173796beaeb57e69cbb58 to your computer and use it in GitHub Desktop.
Save webpage as PDF in C# | C# print web page to PDF
// Load input HTML from URL
HTMLDocument document = new HTMLDocument("https://www.aspose.com");
// Initialize PdfPermissions class object to allow printing and form filling in the PDF document
PdfPermissions permissions = PdfPermissions.PrintDocument | PdfPermissions.FillForm;
// Initialize PdfSaveOptions class object and set the encryption properties
PdfSaveOptions options = new PdfSaveOptions();
options.Encryption = new PdfEncryptionInfo("user", "owner", permissions, Encryption.PdfEncryptionAlgorithm.RC4_128);
// Save output PDF file with encryption
Converter.ConvertHTML(document, options, "URLtoPDF_encrypted.pdf");
// Load input HTML file
HTMLDocument document = new HTMLDocument("https://www.aspose.com");
// Initialize PdfSaveOptions class object
PdfSaveOptions options = new PdfSaveOptions();
// Save webpage as PDF in C#
Converter.ConvertHTML(document, options, "URLtoPDF.pdf");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment