How to Convert HTML to PDF

Products and Services

Almost every SaaS product or service needs to create PDF document in an easy way and sometimes what is an obvious task is not so easy to implement. We are not talking about creating PDF from other programs but creating PDF on-the-fly, for example, when someone buy something in your webshop you want to send him thank you letter together with an attached PDF invoice.

There are free and paid solutions to achieve this task. I will cover here only this topic “How to create PDF in Microsoft .NET and CSharp – C#”.

FREE tools for PDF creation

  1. iTextSharp – you can create PDF from scratch by adding single elements like paragraphs, fonts, tables… This is all done in code but you can also create a library-specific XML with dynamic code inside and then give it to  library to parse it – this way is better and you will have more control. The best thing is that it is free but it is also not so easy to create a nice PDF document – you will need to preview it and tweak it a lot of times before you are completely satisfied because there is no simple visual preview. Documentation is not its main power but there is some: doc-source-1, CodeProject, doc-source-2, api-docs
  2. WKHTMLtoPDF – this library use WebKit to convert HTML pages to PDF. This is super nice scenario, because creating HTML pages is an easy task. We have tried it but were not completely satisfied with the results (we didn’t tried the latest version)

COMMERCIAL tools for PDF creation

  1. There are a lot of them but among all of them we were best satisfied with HiqPDF library. You can download the library from their website and try immediately to check the results. You can even enter the live URL of your website/service at their website  to get instantly generated PDF and see the results. The only difference when using the Trial library is that there is the watermark inside created PDF document and after you purchase the license you will get this removed. Developer license would be the best for 595$ because it allows you as a single developer to use it in unlimited amount of projects.