Convert HTML to PDF Like a Boss Using DocRaptor


(Sponsors) Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!


DocRaptor is an awesome package which allows you to convert your HTML document to PDF. It works with Python 2 and Python 3.

Here are some features of DocRaptor:

  1. Support any size document, with simple, per-document pricing.
  2. Supports layout and sizing changes on a per-page basis
  3. Asynchronous document generation, for long or large documents.
  4. 99.99% uptime guarantee

Installing DocRaptor

To intall DocRaptor using pip type the following command:

You can also use easy_intall:

Creating PDFs

Creating PDF from you HTML docment is quite simple just post your HTML to DocRaptor and you will get the response as text/plain.

Run the script and it will create a pdf file named output.pdf.

The preceding code generates PDF synchronously. Here is how you can generate PDFs asynchronously:


Other Tutorials (Sponsors)

This site generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!


Leave a Reply

Your email address will not be published. Required fields are marked *