# Template being ignored when attaching pdf in e-mail

**URL:** <https://www.ruby-forum.com/t/template-being-ignored-when-attaching-pdf-in-e-mail/131860>\
**Category:** Rails\
**Created:** [March 13, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/template-being-ignored-when-attaching-pdf-in-e-mail/131860 "2008-03-13T23:03:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/838e76/32.png) [@keaja](https://www.ruby-forum.com/u/keaja)\
**Post date:** [March 13, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/template-being-ignored-when-attaching-pdf-in-e-mail/131860/1 "2008-03-13T23:03:30Z")

</div>

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 = “removed\_email\_address@domain.invalid”  
@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
