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 -%>

<%- end -%>

  • <%= link_to 'Print', {:controller => 'receipt', :action => 'print', :id =>, :format => 'pdf'}, :target => 'pdfDoc' %>
  • 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!