DocRaptor Home

How to Make a PDF or Excel Document

Examples & Agents by Programming Languages > Making Documents with Python


pip install --upgrade docraptor


easy_install --upgrade docraptor

If you are on a system with easy_install but not pip, you can use easy_install instead. If you're not using virtualenv, you may have to prefix those commands with sudo.


See examples for runnable examples with file output, error handling, etc.

import docraptor

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

doc_api = docraptor.DocApi()

response = doc_api.create_doc({
  "test": True,                                                   # test documents are free but watermarked
  "document_content": "<html><body>Hello World</body></html>",    # supply content directly
  # "document_url": "", # or use a url
  "name": "docraptor-python.pdf",                                 # help you find a document later
  "document_type": "pdf",                                         # pdf or xls or xlsx
  # "javascript": True,                                           # enable JavaScript processing
  # "prince_options": {
  #   "media": "screen",                                          # use screen styles instead of print styles
  #   "baseurl": "",                              # pretend URL when using document_content
  # },

Docs created like this are limited to 60 seconds to render, check out the async example which allows 10 minutes.

Ready to get started? Try DocRaptor for free with unlimited test documents.