The following code attaches my pdf with success. However, my e-mail
template is not being rendered in the e-mail. Any idea’s why my
template is ignored?
require ‘pdf/writer’
class NotifierRequest < ActionMailer::Base
def inforequest(name, email, notice_request, message)
@subject = ‘Notice’
@body = {:name => name, :email => email, :notice_request
=> notice, :message => message}
@recipients = email
@from = “[email protected]”
@sent_on = Time.now
@content_type = “text/html”
attachment :content_type => "application/pdf", :filename =>
“notice.pdf”, :transfer_encoding => “send_pdf” do |a|
a.body = generate_pdf(notice_request)
end
end
def generate_pdf(notice_request)
pdf = PDF::Writer.new(:paper => "LETTER")
pdf.select_font 'Times-Roman'
pdf.text "HELLO WORLD", :font_size => 17, :justification
=> :center
pdf.move_pointer(5)
pdf.render :filename => 'NoticeRequest.pdf', :type =>
‘application/pdf’
end
end