[Rails] Print a PDF directly after prawnto with iframes
Hi,
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;
pdf.focus();
pdf.print();
}
</script>
<%- end -%>
<iframe src="/aaa.pdf" id="pdfDoc" name="pdfDoc"></iframe>
<li><%= link_to 'Print', {:controller => 'receipt', :action => 'print',
:id => @receipt.id, :format => 'pdf'}, :target => 'pdfDoc' %></li>
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!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home