Reviews

How to Convert HTML to PDF or XLS.

Converting HTML to PDF or XLS can be a little bit challenging especially when the output size of the PDF is large.

In fact, not having control of the layout and styles of individual pages of your document can be very annoying. Tables and images will mess up your document.

Today, I will tell you how to convert HTML to PDF without sweat. There will be complete control of your document including adding of watermarks.

DocRaptor, HTML-to-PDF converterDocRaptor is an online service that can be used to generate PDF, XLS files from HTML at an affordable price.

There’s a 7-day free trial so you can have a chance to try it out first before paying for a plan.

They are so affordable that you pay 9 cents per document when you pay for a professional plan.

Here are docraptor plans and pricing below.

docraptor plans and pricing for converting html to pdf

Converting HTML to PDF with Docraptor

DocRaptor has libraries for PHP, Python(supports for both 2.x and 3.x), Node.js, Ruby, Java, .NET, and JavaScript/jQuery, etc for converting HTML, CSS and Javascript into PDF and XLS documents.

You can easily install DocRaptor library with pip via command prompt or terminal on windows or mac respectively.

install docraptor library with pip

After installing, all you need to do to use Docraptor is to submit a POST request, supplying certain options and the document you want to convert, giving the content directly or providing a URL. You also need the API Key supplied with your paid account.

Some of these options are:

  • type: this is the type of document you want to generate. It can be PDF or excel files
  • document_content: this is the HTML code snippet you want to convert to PDF or XLS
  • document_url: this is the webpage url to convert to PDF or XLS files.
  • name: this option can be ignored. It is a string to describe and identify the document

Other options are found here.

HTML with only tables are converted to XLS files.

The above code snippet generates a PDF from one of my blog post urls and creates a pdf file named pythonbook.pdf. It also generates the PDF synchronously.

 

 

 

About the author

Rapture Godson

I am Godson; the brain behind Cool Python Codes. On this blog, I will make Python much fun and very practical. My up-to-date tutorials are based on my studies and they are very easy for you to understand.