Home

Awesome

DocRaptor Ruby Native Client Library

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

Basic Usage

DocRaptor.configure do |config|
  config.username = "YOUR_API_KEY_HERE" # this key works for test documents
  # config.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
  # },
)

Next Steps

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.

Release Process

  1. Pull latest master
  2. Merge feature branch(es) into master
  3. script/test
  4. Increment version: generator-config.json
  5. Run script/generate_language to update generated version numbers:
  1. Update CHANGELOG.md
  2. Commit "Release version vX.Y.Z"
  3. script/release
  4. Verify package release at https://rubygems.org/gems/docraptor
  5. Refresh documentation on docraptor.com

Version Policy

This library follows Semantic Versioning 2.0.0.