Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Print a PDF file
3 Posts
Print a PDF file

Hello

I have a PDF file and I want to print it when I click on a button of my rails application. I also want, if it is possible, to be possible the user choose the printer to be used. How can I do that? thanks regards

Probably with JavaScript. In many browsers, window.print() will display the system Print dialog, exactly as if the user had chosen the browser's Print command.

I don't think it's possible to be honest. PDF files rely on external viewer apps. Any viewers that work in the browser are probably because your viewer supports viewing through ActiveX or something simmilar. Either way you can't not use JavaScript.

The only way that might work, which is a hacky kludge is to use an iframe created with javascript and then call the print() method for that frame from the host frame/page.

3 Posts
Login to add your message