Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andersonfernandes/puppet_pdf
PDF generation solution in Ruby using puppeteer
https://github.com/andersonfernandes/puppet_pdf
pdf-generation puppeteer rails
Last synced: 2 months ago
JSON representation
PDF generation solution in Ruby using puppeteer
- Host: GitHub
- URL: https://github.com/andersonfernandes/puppet_pdf
- Owner: andersonfernandes
- License: mit
- Created: 2019-02-26T20:36:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T20:06:49.000Z (almost 2 years ago)
- Last Synced: 2024-11-14T13:43:53.761Z (2 months ago)
- Topics: pdf-generation, puppeteer, rails
- Language: Ruby
- Homepage: https://rubygems.org/gems/puppet_pdf
- Size: 82 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Gem Version](https://badge.fury.io/rb/puppet_pdf.svg)](https://badge.fury.io/rb/puppet_pdf) [![Build Status](https://travis-ci.org/andersonfernandes/puppet_pdf.svg?branch=master)](https://travis-ci.org/andersonfernandes/puppet_pdf) [![Maintainability](https://api.codeclimate.com/v1/badges/d7347b2b2ab3ffdc4668/maintainability)](https://codeclimate.com/github/andersonfernandes/puppet_pdf/maintainability)
# PuppetPdf
PuppetPdf is a lib that wraps [Google Puppeteer](https://pptr.dev/) pdf generation method to be used with Rails.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'puppet_pdf'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install puppet_pdf
Run this task to install some dependencies:
$ rails puppet_pdf:install_dependencies
## Usage
### Render in a controller
```ruby
class TasksController < ApplicationController
def pdf
render_pdf
end
end
```You can pass some options to `render_pdf` like template, layout and the output filename. The available options are:
```ruby
{
template: String, # The template to be rendered. Default: 'controller_path/action_name'
layout: String, # Default: 'application'
filename: String, # Default: 'action_name.pdf'
header: String, # The header of the pdf. Default: ''
footer: String, # The header of the pdf. Default: ''
margins: Hash, # The margins of the pdf. Default: { top: 36, right: 36, bottom: 45, left: 36 }
loading_delay: Integer, # Time to load the page javascript in ms. Default: 1000
output_path: String # The output path of the pdf. Default: generated by Tempfile
}
```### View Helpers
In you views you need to replace `stylesheet_link_tag` with `puppet_stylesheet_link_tag`, and `javascript_include_tag` with `puppet_javascript_script_tag````html
PuppetPdfExample
<%= csrf_meta_tags %>
<%= csp_meta_tag %><%= puppet_stylesheet_link_tag('application.css') %>
<%= puppet_javascript_script_tag('application.js') %>
<%= yield %>
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puppet_pdf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the PuppetPdf project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/puppet_pdf/blob/master/CODE_OF_CONDUCT.md).