Dhalang Build Status

Dhalang is a Ruby wrapper for Google's Puppeteer.


  • Generate PDFs from pages
  • Generate PDFs from html ( external images/stylesheets supported )

More will come.


Add this line to your application's Gemfile:

gem 'dhalang'

And then execute:

$ bundle update

Install puppeteer in your application's root directory:

$ npm install puppeteer

NodeJS v7.6.0 or greater is required


Get a PDF of a website url
It is important to pass the complete url, leaving out https://, http:// or www. will result in an error.

Get a PDF of a HTML string

Both methods return a string containing the PDF in binary.

To return the PDF from a Rails controller you can do the following:

def example_controller_method  
    binary_pdf = Dhalang::PDF.get_from_url("https://www.google.com")  
    send_data(binary_pdf, filename: 'pdfofgoogle.pdf', type: 'application/pdf')