Making Documents with Ruby
James Paden avatar
Written by James Paden
Updated over a week ago

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"
  # dr.debugging = true
end

$docraptor = DocRaptor::DocApi.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.

Did this answer your question?