DocRaptor Ruby Native Client Library
WARNING: This code is not production ready, you should use doc_raptor_gem.
This is a Ruby gem for using DocRaptor API to convert HTML to PDF and XLSX.
Installation
Add the following to your Gemfile
.
gem "docraptor"
Then run bundle install
.
Usage
See examples for runnable examples with file output, error handling, etc.
DocRaptor.configure do |dr|
dr.username = "YOUR_API_KEY_HERE" # this key works for test documents
# dr.debugging = true
end
$docraptor = DocRaptor::ClientApi.new
response = $docraptor.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-ruby.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
- Protected Content to secure your URLs so only DocRaptor can access them
More Help
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.
Development
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 ruby
.
The generated client needed a few fixes
- binary string response code generated from https://github.com/swagger-api/swagger-codegen/pull/1934
Release Process
script/test
- Increment version in code:
swagger-config.json
docraptor.gemspec
- Update CHANGELOG.md
rake release
Version Policy
This library follows Semantic Versioning 2.0.0.