# Print a PDF directly after prawnto with iframes

**URL:** <https://www.ruby-forum.com/t/print-a-pdf-directly-after-prawnto-with-iframes/180979>\
**Category:** Rails\
**Created:** [January 2, 2010, 7:03pm UTC](https://www.ruby-forum.com/t/print-a-pdf-directly-after-prawnto-with-iframes/180979 "2010-01-02T19:03:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kinunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kinunt](https://www.ruby-forum.com/u/kinunt)\
**Post date:** [January 2, 2010, 7:03pm UTC](https://www.ruby-forum.com/t/print-a-pdf-directly-after-prawnto-with-iframes/180979/1 "2010-01-02T19:03:53Z")

</div>

Hi,

I think I’m very near of accomplishing this but I have a problem.  
This is the code:

\<%- content\_for :head do -%\>

\<%- end -%\>

- \<%= link\_to 'Print', {:controller =\> 'receipt', :action =\> 'print', :id =\> @receipt.id, :format =\> 'pdf'}, :target =\> 'pdfDoc' %\>

And the print action:

def print  
@receipt= Receipt.find(params[:id])  
prawnto :inline =\> true, :filename =\> “receipt\_#{@receipt.codigo}”  
end

Now when I click in the link ‘Print’ the iframe is reloaded with the pdf  
generated by prawn but I don’t know how to call then the printPDF  
javascript function. If I just could call this javascript from the  
controller (with ajax) or from the view with javascript after the iframe  
is reloaded I would solve my problem.

Any help will be really appreciated!
