开发者

How do I email a PDF generated using PDFKit and on Heroku in Rails?

开发者 https://www.devze.com 2023-02-10 06:36 出处:网络
I am using PDFKit on Heroku (and also locally for dev) and am having difficulty emailing the generating PDF from my cron task.

I am using PDFKit on Heroku (and also locally for dev) and am having difficulty emailing the generating PDF from my cron task.

This is the code in my cron job:

     kit = PDFKit.new(html_file) 
     file = kit.to_pdf 

     OutboundMailer.deliver_pdf_email(file) 
     #kit.render_file("pdf_from_cron.pdf") 

This is the code in my Mailer:

 def pdf_email(pdf)
  subject     "This is your batch of letters"
  recipients  "helloworld@gmail.com"
  from        "B开发者_开发知识库atch Email <hello@batch.com>"
  sent_on     Date.today
  body        "This is the body of pdf"

  attachment "application/pdf" do |a|
    a.filename = "batch-letters.pdf"
    a.body = pdf
  end

end


I setup PDFKit on Heroku once and followed: http://blog.mattgornick.com/using-pdfkit-on-heroku. You may need to include the binary.

0

精彩评论

暂无评论...
验证码 换一张
取 消