Sha256: 4ef12ca6b2a5e40e629c7677be0e2c47ac105339e251b96f5825ce6ffd86c3d8

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

# Pdfgen
A tool for creating PDFs using [Puppeteer](https://github.com/GoogleChrome/puppeteer) and headless Chrome.

# Dependencies
This gem requires that node be installed along with puppeteer.

### OSX (Homebrew)
To install node on OSX you can use Homebrew:
```bash
brew install nodejs
```

And then install puppeteer with npm:
```bash
npm install --save puppeteer
```

# Usage
Currently the only use case that is supported is rendering an HTML string. You can do that by using the
Pdfgen class:
```ruby
pdf_as_string = Pdfgen.new(html_to_turn_into_pdf).to_pdf
```
`to_pdf` returns the pdf as a string. This makes it easy to send to a client from a web server like
Rails or to save to a file if that is desired.

If you need to provide options such as page margins you can pass them as a hash to `to_pdf`. Any 
options that work for [Puppeteer's `pdf` method](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions)
are accepted as they are passed through without modification.
```ruby
pdf_as_string = Pdfgen.new(html_to_turn_into_pdf).to_pdf(margins: { top: '1in', bottom: '1in' })
``` 

# Future Development
In the future, allowing use of more features of Puppeteer is desired. These include taking a URL and 
setting cookies. Instead of using a fixed make_pdf.js script, it will probably make sense to convert
to generating that javascript file on the fly using templates since additional options like allowing
the setting of cookies will require calling more functions than are currently being called.

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pdfgen-0.3.1 README.md
pdfgen-0.3.0 README.md
pdfgen-0.2.1 README.md
pdfgen-0.2.0 README.md
pdfgen-0.1.0 README.md