A lot of cases come around where you may need a HTML to PDF Converter from a web page while keeping the format and feel of the web page. I’ve reached a point in one of my projects where that’s exactly what I needed. So I started hunting and found a few “meh” free HTML to PDF converters and a good amount of pay-to-play converters. Unfortunately, it’s hard (or almost impossible) to find JavaScript converters because the conversion process is almost always a conversion of the data bytes.
The problem with the free HTML to PDF Converters are that the quality is not there for what I needed. I was producing corporate documents from HTML ASP data pages. The engines that drive the conversion sometimes wonked images, skewed the form and style, or just didn’t work as expected. I had to bring in the big guns and dish out for a purchased converter.
I settled on ExpertPDF (http://www.html-to-pdf.net/Pricing.aspx) to get the job done. With a few config lines within my C#, I’m able to batch out PDF’s to a specified location with a specified name. ExpertPDF has built in methods to take care of functionality such as page numbers, header/footer, and page width. I leveraged ExpertPDFs ability to let me control that and created a Web Part in SharePoint 2010 to allow the user define where to save the final PDF and what to name it.
The pricing for ExpertPDF HTML to PDF Converter is reasonable compared to other tools that we’ve found and allows a one-time purchase options that lets us develop per-Company rather than per-devloper.
Sample Config
protected PdfConverter GetPdfConverter() { PdfConverter pdfConverter = newPdfConverter(); pdfConverter.PageWidth = 1450; autodetect the HTML page width pdfConverter.PageHeight = 850; PdfConverter.LayoutHtmlTimeoutSec = 500; pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4; pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Landscape; pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal; pdfConverter.PdfDocumentOptions.FitHeight = true; pdfConverter.PdfDocumentOptions.FitWidth = true; pdfConverter.PdfDocumentOptions.ShowHeader = false; pdfConverter.PdfDocumentOptions.ShowFooter = false; pdfConverter.PdfDocumentOptions.LeftMargin = 3; pdfConverter.PdfDocumentOptions.RightMargin = 3; pdfConverter.PdfDocumentOptions.TopMargin = 3; pdfConverter.PdfDocumentOptions.BottomMargin = 3; pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true; pdfConverter.PdfFooterOptions.ShowPageNumber = false; pdfConverter.ScriptsEnabled = pdfConverter.ScriptsEnabledInImage = true; pdfConverter.AuthenticationOptions.Username = "USERNAME"; pdfConverter.AuthenticationOptions.Password = "PASSWORD"; //Set the license key dfConverter.LicenseKey = "<>"; return pdfConverter; }
Other Options
- PDF Crowd (http://pdfcrowd.com/web-html-to-pdf-net/)
- We chose not to use this one because of the cost. We did not want to pay a monthly subscription. For small scale needs, this might be just the ticket when factoring cost.
- Dynamic PDF (http://www.dynamicpdf.com/PDF-Conversion-.NET.aspx)
- Allows not just HTML, but DOC or DOCX conversion. Very versatile with a broad range of conversion sources.
- Magnetic PDF (http://www.magneticpdf.com/Features.aspx)
- This little guy allows you to also generate PDFs with control over the page breaks from CSS.
One thought on “ASP.Net HTML to PDF Converter – ExpertPDF”
good title