ruby - Is it possible to generate PDF from rails and automatically attach to a mailer? -


Similar to the question, I want to generate a PDF document with some content from the database. Attach it to the email Do you think you can get gem like rogue pdf or shrimp?

edit I have HelloOu setup, does it affect my ability to use PDPDF and WKPDF2 HTMT?

You can also generate PDFs from HTML and PDFKit

You can add your mail using the code inside your controller here

  html = render_to_string (: partial = & gt; "confirmation ") Pdfkit_instance = PDFKit.new (html) UserMailer.registration_confirmation (@ user, pdfkit_instance.to_pdf) .deliver  

The following in your mailer class

  DER Registration_confirmation (user, pdf_file) attachment ["# {user.company_name} _ # {time.now.strftime ("% m% d_% Y ") = .pdf "] = pdf_file mail (: = =" gtc: "# {user.name}", & lt; # {user.email} & gt; ",: subject =>" yoursubject "end  

To set up PDF, you can go through the blog


Comments