Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help documentation for adding to email #746

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ config.middleware.use WickedPdf::Middleware, {}, except: [ %r[^/admin], '/secret
```
If you use the standard `render pdf: 'some_pdf'` in your app, you will want to exclude those actions from the middleware.


### Include in an email as an attachment

To include a rendered pdf file in an email you can do the following:

```ruby
attachments['attachment.pdf'] = WickedPdf.new.pdf_from_string(
render_to_string('link_to_view.pdf.erb', layout: 'pdf')
)
```

This will render the pdf to a string an include it in the email. This is very slow so make sure you schedule your email delivery in a job.

### Further Reading

Mike Ackerman's post [How To Create PDFs in Rails](https://www.viget.com/articles/how-to-create-pdfs-in-rails)
Expand Down