This is a Python package for using DocRaptor API to convert HTML to PDF and XLSX. It is compatible with Python 2 and Python 3.
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
.
See examples for runnable examples with file output, error handling, etc.
import docraptor
docraptor.configuration.username = "YOUR_API_KEY_HERE" # this key works for test documents
# 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": "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
# },
})
Docs created like this are limited to 60 seconds to render, check out the async example which allows 10 minutes.
We have guides for doing some of the common things:
- Headers and Footers including page skipping
- CSS Media Selector to make the page look exactly as it does in your browser
- Protect content with HTTP authentication or proxies so only DocRaptor can access them
DocRaptor has a lot of more styling and implementation options.
Stuck? We're experts at using DocRaptor so please email us if you run into trouble.
The majority of the code in this repo is generated using swagger-codegen on docraptor.yaml. You can modify this file and regenerate the client using script/generate_language python
.
The generated client needed a few fixes
- Pull latest master
- Merge feature branch(es) into master
script/test
- Increment version in code:
swagger-config.json
setup.py
docraptor/api_client.py
docraptor/configuration.py
- Update CHANGELOG.md
- Commit "Release version vX.Y.Z"
- Push to GitHub
- Tag version:
git tag 'vX.Y.Z' && git push --tags
- Clean out any old packages
rm dist/*
- Build packages
python setup.py sdist bdist_wheel
- Upload packages
twine upload dist/*
- Verify package release at https://pypi.python.org/pypi/docraptor
- Update documentation on docraptor.com
This library follows Semantic Versioning 2.0.0.