DocRaptor review

Hi everyone, I was recently contacted by the folks at DocRaptor telling me about their service so I decided to take it for a test drive and see for myself what it actually is.

DocRaptor provides you with an API to generate PDF and XLS files from HTML and CSS files. Today we will take a look at how we can use it to generate the PDF for a payment receipt.

Step 1: Install the Required Dependencies

We need to install the docraptor package.

pip install --upgrade docraptor

We also need to signup for a trial on DocRaptor.

Step 2: Test Document Generation

Try running the sample code to make sure that everything is working:

If the above code works without any errors then you should have a test.pdf file in the working directory. You can check out the official Python docs on DocRaptor’s website.

Now let’s move on and actually create a simple receipt HTML template and use that to generate a receipt.

Step 3: Creating a Custom Template

Now we can go ahead and code up a template from scratch but what if I told you that DocRaptor already provides you with some templates which you can customize and quick start your pdf generation journey?

Let’s customize a DocRaptor template. This is the code for a receipt template which DocRaptor has on its website:


Let’s customize it to reflect the Python Tips brand.


I customized the logo, header, footer and table data and also added a “Paid” stamp below the total amount. I had to make only minimal changes in the template and now I have a really beautiful receipt template which I can use to generate PDFs.

Now run the Python code again but this time change the

"test": True

to

"test": False

If everything works fine you should end up with a similar PDF:

Screen Shot 2018-01-25 at 8.27.40 PM

The usefulness of DocRaptor comes in when you have to generate tons of PDF files on the fly without utilizing a lot of your own system’s resources.

In a future post we will take a look at using Python to generate PDFs and you will see how tedious it can get. I don’t really have any need to generate so many PDFs so I can’t comment on whether DocRaptor is expensive or worth-it but it sure is a convenient service.

If you have read this far then please go ahead and give DocRaptor a try. You can avail a 10% discount by emailing DocRaptor support and mentioning this blog post.

Stay tuned for more posts in the future!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s