Print a PDF directly after prawnto with iframes


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

<%- content_for :head do -%>
  <script type="text/javascript" charset="utf-8">
    function printPDF(){
      var pdf = document.getElementById("pdfDoc").contentWindow;
<%- end -%>

<iframe src="/aaa.pdf" id="pdfDoc" name="pdfDoc"></iframe>

<li><%= link_to 'Print', {:controller => 'receipt', :action => 'print',
:id =>, :format => 'pdf'}, :target => 'pdfDoc' %></li>

And the print action:

  def print
    @receipt= Receipt.find(params[:id])
    prawnto :inline => true, :filename => "receipt_#{@receipt.codigo}"

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!