Tuesday, March 21, 2023
HomePythonDocRaptor evaluate - Yasoob Khalid

DocRaptor evaluate – Yasoob Khalid

Hello everybody, I used to be just lately contacted by the parents at DocRaptor telling me about their service so I made a decision to take it for a take a look at drive and see for myself what it truly is.

DocRaptor offers you with an API to generate PDF and XLS recordsdata from HTML and CSS recordsdata. At present we’ll check out how we will use it to generate the PDF for a fee receipt.

Step 1: Set up the Required Dependencies

We have to set up the docraptor package deal.

pip set up --upgrade docraptor

We additionally must signup for a trial on DocRaptor.

Step 2: Check Doc Era

Attempt operating the pattern code to make it possible for the whole lot is working:

import docraptor

docraptor.configuration.username = "******************"
# docraptor.configuration.debug = True

doc_api = docraptor.DocApi()

with open('take a look at.html', 'r') as f:
    test_html = f.learn()

response = doc_api.create_doc({
  "take a look at": True,                                                   # take a look at paperwork are free however watermarked
  "document_content": str(test_html),    # provide content material instantly
  # "document_url": "http://docraptor.com/examples/bill.html", # or use a url
  "identify": "docraptor-python.pdf",                                 # enable you to discover a doc later
  "document_type": "pdf",                                         # pdf or xls or xlsx
  # "javascript": True,                                           # allow JavaScript processing
  # "prince_options": {
  #   "media": "display screen",                                          # use display screen kinds as a substitute of print kinds
  #   "baseurl": "http://howdy.com",                              # faux URL when utilizing document_content
  # },

with open('take a look at.pdf', 'wb') as f:

If the above code works with none errors then you need to have a take a look at.pdf file within the working listing. You’ll be able to take a look at the official Python docs on DocRaptor’s web site.

Now let’s transfer on and really create a easy receipt HTML template and use that to generate a receipt.

Step 3: Making a Customized Template

Now we will go forward and code up a template from scratch however what if I informed you that DocRaptor already offers you with some templates which you’ll be able to customise and fast begin your pdf era journey?

Let’s customise a DocRaptor template. That is the code for a receipt template which DocRaptor has on its web site:


Let’s customise it to replicate the Python Suggestions model.


I personalized the brand, header, footer and desk information and likewise added a “Paid” stamp under the full quantity. I needed to make solely minimal adjustments within the template and now I’ve a extremely lovely receipt template which I can use to generate PDFs.

Now run the Python code once more however this time change the

"take a look at": True


"take a look at": False

If the whole lot works high quality you need to find yourself with an analogous PDF:


The usefulness of DocRaptor is available in when you need to generate tons of PDF recordsdata on the fly with out using numerous your personal system’s assets.

In a future publish we’ll check out utilizing Python to generate PDFs and you will note how tedious it may well get. I don’t actually have any must generate so many PDFs so I can’t touch upon whether or not DocRaptor is dear or worth-it nevertheless it certain is a handy service.

In case you have learn this far then please go forward and provides DocRaptor a strive. You’ll be able to avail a ten% low cost by emailing DocRaptor assist and mentioning this weblog publish.

Keep tuned for extra posts sooner or later!



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments