No description, website, or topics provided.
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Doc-Juan's Helper

A small helper class to generate urls to a Doc-Juan instance.

Give a url, a filename and options the DocJuan to generate a url to a DocJuan server including the calculated hmac key.


Required configuration

You need to provide your secret key and the host of the Doc-Juan instance.

DocJuan.configure do |config| = ''
  config.secret = 'my-special-secret'

If you are using Rails an initializer would be the appropriate place for this.


If your site is behind HTTP Basic Authentication DocJuan.config.username and DocJuan.config.password is your friends.

BEWARE! Setting these will append your credentials to every DocJuan url generated and, depending on how you use them, can be fully visible to your users. The authentication credentials is foremost available for testing in your staging environment.

Generating urls

The DocJuan.url method generates a url to your Doc-Juan instance. It takes an url and a filename as the required arguments. You can supply an (optional) hash of options as the third argument.

Valid options are:

  • title - PDF title, defaults to the title of the HTML document.
  • print_stylesheet - If set to true the print stylesheet of the resource will be used.
  • width - Page width in millimeters.
  • height - Page height in millimeters.
  • size - a4, letter etc. This will be ignored if width and height is set. List of sizes.
  • orientation - landscape or portrait. Defaults to portrait.
  • lowquality - Renders the pdf in low quality if set to true.
  • format - Output file format, pdf or jpg. Defaults to pdf.


url = DocJuan.url '', 'example.pdf'

url = DocJuan.url '', 'le-pdf.pdf', title: 'My PDF-version', size: 'A5'


Add this line to your application's Gemfile:

gem 'doc_juan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install doc_juan


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request