Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created February 29, 2020 02:22
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/ad68c928411bded41103ded76e6554c6 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/ad68c928411bded41103ded76e6554c6 to your computer and use it in GitHub Desktop.
WebRequest req = WebRequest.Create(@"https://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html");
// Get web page into stream
using (Stream stream = req.GetResponse().GetResponseStream())
{
// Initialize HTML load options
HtmlLoadOptions htmloptions = new HtmlLoadOptions("https://docs.oracle.com/");
// Load stream into Document object
Document pdfDocument = new Document(stream, htmloptions);
// Save output as PDF format
pdfDocument.Save("HTML-to-PDF.pdf");
}
// Create HTML load options
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// Load HTML file
Document doc = new Document("HTML-Document.html", htmloptions);
// Set encryption parameters
doc.Encrypt("userpassword", "ownerPassword", Permissions.ModifyContent, CryptoAlgorithm.AESx256);
// Convert HTML file to PDF
doc.Save("HTML-to-PDF.pdf");
// Create HTML load options
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// Load HTML file
Document doc = new Document("HTML-Document.html", htmloptions);
// Convert HTML file to PDF
doc.Save("HTML-to-PDF.pdf");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment