DocRaptor

The DocRaptor add-on allows you to create PDF and XLS documents on the fly from your application using the DocRaptor webservice. Your application passes in HTML and some options, you get a pdf or an excel file back.

Deploying to Heroku

To use DocRaptor on Heroku, install the add-on:

$ heroku addons:add docraptor

And either add the doc_raptor gem to your Gemfile (if you are on Bundler):

gem "doc_raptor"

or, if you are not yet on Bundler, add it to your .gem file:

doc_raptor

and your environment.rb:

config.gem "doc_raptor"

Local setup

To use this add-on, you will need to install the doc_raptor gem. In production, the gem will be configured automatically by Herkou environment variables. In development or testing however, you will need to set the “DOCRAPTOR_API_KEY” environment variable yourself – you can find the correct value for this variable for your application after adding the DocRaptor addon by running:

$ heroku config

which will output all the environment varaibles that heroku is currently setting for your production app.

Using DocRaptor

Once you have the gem installed, creating documents is as easy as calling:

>> DocRaptor.create(:document_content => "<html><body>Some HTML!</body></html>", 
   :document_type => "pdf")

This call returns a HTTParty reponse object whose body is the generated pdf or excel file. You can find out much more about the options for this call and what you can pass in as content through the links below.

Further reading: