DocRaptor CLI

WARNING: This is a beta client and subject to serious change

This is a command line interface for using DocRaptor API to convert HTML to PDF and XLSX.


gem install docraptor-cli


docraptor local_file.html                              # local files
docraptor  # URLs are detected by prefix

The full DocRaptor API is available, see:

Usage: docraptor [options] <url/file>

Server options:
    -k, --key KEY                    The API Key to use when calling the service. Defaults to YOUR_API_KEY_HERE or ENV[DOCRAPTOR_API_KEY].
    -s, --server SERVER              Make API requests against SERVER, scheme not required. Defaults to

Document options:
        --async                      Create document asynchronously(10 min limit). Defaults to synchronous(1 min limit).
    -d, --debug                      Enable debug logging.
        --no-ignore-resource-errors  Error when a resource cannot be downloaded.
    -j, --javascript                 Enable DocRaptor JavaScript parsing. Defaults to no javascript.
        --name NAME                  Give a name to this document. Defaults to a randomized string. Does not affect output filename.
        --referrer URL               Set HTTP REFERRER when rendering. Defaults to localhost for file rendering or render url.
        --strict STRICTNESS          Set HTML strictness. Defaults to none.
        --test                       Create this as a test document. Defaults to non-test.
    -t, --type TYPE                  Type of document to make, can be pdf, xls, xlsx. Defaults to pdf.

Prince options:
        --prince-baseurl URL         Set base url when rendering. Defaults to nothing for file rendering or render url.
        --prince-css-dpi DPI         Set a base CSS DPI. Defaults value used by Prince is 96.


We have guides for doing some of the common things:

Testing Callbacks

The --callback-url option can be used to set a URL that will receive a POST request after your document has successfully been processed. You can simulate this in your *nix development environment using a couple of simple tools: nc and ngrok.

Let's say you had some document content in a file named test.html. To test the callback URL, start a new console and type:

nc -lk 9001

This will listen on port 9001 for requests. Now open another console and type in:

ngrok http 9001

This will setup an external URL that port forwards to port 9001 on your computer (conveniently being listened to by nc). Note the ngrok http URL. It should look something like Copy that URL and open a third console where we will generate our document:

bin/docraptor test.html --async --callback_url ""

After the document has been generated, if we go to our console running nc, we should see we got an HTTP POST request that looks something like this:

Connection: close
Content-Length: 139
Content-Type: application/x-www-form-urlencoded

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.


This code is a thin wrapper around the docraptor gem to make it suitable for command line users.

Release Process

  1. Pull latest master
  2. Merge feature branch(es) into master
  3. script/test
  4. Increment version in code:
    • lib/docraptor-cli/version.rb
  5. Update
  6. Commit "Release vX.Y.Z"
  7. rake release

Version Policy

This library follows Semantic Versioning 2.0.0.