Skip to content

A native Python client for the DocRaptor document generation service.

License

Notifications You must be signed in to change notification settings

DocRaptor/docraptor-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocRaptor Python Native Client Library

This is a Python package for using DocRaptor API to convert HTML to PDF and XLSX. It is compatible with Python 3.

Installation

pip install --upgrade docraptor

or

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.

Basic Usage

import docraptor

doc_api = docraptor.DocApi()
doc_api.api_client.configuration.username = 'YOUR_API_KEY_HERE'   # this key works for test documents
# doc_api.api_client.configuration.debug = True

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": "http://docraptor.com/examples/invoice.html", # 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": "http://hello.com",                              # pretend URL when using document_content
  # },
})

Next Steps

  • Optionally store and get a URL for your converted document with document hosting
  • View more code examples with error handling, asynchronous creation, file saving, and document hosting.
  • Perfect your document styling with our style and formatting reference, and API reference. Easily add headers and footers, page breaks, page numbers, table of contents, and much more!

More Help

Stuck? We're experts at turning HTML into PDFs so please email us if you run into trouble.

Development

The majority of the code in this repo is generated using openapi-generator on docraptor.yaml. You can modify this file and regenerate the client using script/generate_language.

The generated client needed a few fixes

Release Process

  1. Pull latest master
  2. Merge feature branch(es) into master
  3. script/test
  4. Increment version:
  • generator-config.json
  1. Run script/generate_language to update generated version numbers:
  • docraptor/__init__.py
  • docraptor/api_client.py
  • docraptor/configuration.py
  • setup.py
  1. Update CHANGELOG.md
  2. Commit "Release version vX.Y.Z"
  3. Push to GitHub
  4. Tag version: git tag 'vX.Y.Z' && git push --tags
  5. script/release
  6. Verify package release at https://pypi.python.org/pypi/docraptor
  7. Update documentation on docraptor.com

Version Policy

This library follows Semantic Versioning 2.0.0.

About

A native Python client for the DocRaptor document generation service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published