HTML to PDF Byte Array
How to Convert HTML to PDF Byte Array in C#
The following steps and sample code illustrate how to quickly convert HTML to a PDF byte array using the DynamicPDF HTML Converter product. Basic HTML to PDF conversion can be done with one method call, however, if required advanced ConversionOptions class can be used.
Steps for Creating a PDF Document from HTML
- Reference DynamicPDF HTML Converter from Nuget (ID: ceTe.DynamicPDF.HtmlConverter.NET).
- Add a using statement for
ceTe.DynamicPDF.HtmlConverter
. - Invoke the
Convert
method on theHtmlConverter
and specify the PDF file name.
Sample Code - C#
//be certain to use ceTe.DynamicPDF.HtmlConverter
byte[] pdfByteArray = Converter.Convert(new Uri("https://www.google.com"));
File.WriteAllBytes("ConvertToByteArray.pdf", pdfByteArray);
Getting Started
NuGet Package
DynamicPDF HTML Converter is available on NuGet in the ceTe.DynamicPDF.HtmlConverter.NET
package. The easiest way to install the package is through the Visual Studio Package Manager. You can also download directly from NuGet.
NuGet Package ID: ceTe.DynamicPDF.HtmlConverter.NET
Example Project
Clone or View Example Project on GitHub