Reputation: 125
I filled the pdf using pdf_forms gem , now i want to convert that pdf into binary and want to send via email.
Upvotes: 2
Views: 1025
Reputation: 7141
You probably just want to send the pdf as an attachment. The official Rails ActionMailer has an example on how to do this
class UserMailer < ActionMailer::Base
def welcome_email(user)
@user = user
@url = user_url(@user)
attachments['terms.pdf'] = File.read('/path/terms.pdf')
mail(:to => user.email,
:subject => "Please see the Terms and Conditions attached")
end
end
http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-attachments
Upvotes: 1
Reputation: 29599
you dont need to convert a pdf to binary to attach it to an email. just add this line inside the method of your mailer
attachments["filename.pdf"] = File.read("/path/to/filename.pdf")
Upvotes: 1