HTML to PDF Conversion

DynamicPDF HTML Converter supports converting HTML from a URL and HTML from a local file or text string. Both conversion methods use the Converter.Convert method, but the method is overloaded to take either a Uri object or a text string.

URL to PDF

Converting HTML to PDF using a URL requires passing a URL and an path to save the converted PDF document. Converting a URL to a PDF is straightforward, as the following C# and VB .NET examples illustrate.

Converter.Convert(new Uri("http://www.google.com"), "output.pdf");
Converter.Convert(New Uri("http://www.google.com"), "output.pdf")

HTML string to PDF

Converting an HTML document to PDF using HTML markup from a string is also straightforward, as the following C# and VB .NET examples illustrate.

Converter.Convert(htmlString, "output.pdf");
Converter.Convert(htmlString, "output.pdf")

Converting to a Byte Array

Converting to a byte array Converter.Convert method to return a byte array rather than specifying an output file. The following example illustrates.

Uri document = new Uri("https://cnn.com");
byte[] output = Converter.Convert(document);
Dim document As Uri = New Uri("https://cnn.com")
Dim output As Byte() = Converter.Convert(document)

In this topic