2

I filled the pdf using pdf_forms gem , now i want to convert that pdf into binary and want to send via email.

2 Answers 2

1

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")

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.