Sha256: d012c36222a2b27e42345baec852d74895b000f171bd3793447f859c948eb717
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# Dhalang [](https://travis-ci.com/NielsSteensma/Dhalang) > Dhalang is a Ruby wrapper for Google's Puppeteer. ## Features * Generate PDFs from pages * Generate PDFs from html ( external images/stylesheets supported ) More will come. ## Installation 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 <sub>NodeJS v7.6.0 or greater is required</sub> ## Usage __Get a PDF of a website url__ `Dhalang::PDF.get_from_url("https://www.google.com")` 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__ `Dhalang::PDF.get_from_html("<html><head></head><body><h1>examplestring</h1></body></html>")` 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') end ```
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Dhalang-0.2.0 | README.md |