how to print from ruby?

Hi,     I am generating some pdf through a for loop. now i want to print those pdf file through program. Any help/suggestion will be appreciated.

Thanks in advance.

  1. Buy a network enabled printer that supports PDF printing with some kind of upload support (e.g. FTP server)

  2. Buy an application that enables you to upload the file to it and thus add it to a queue and then send it to the printer, look around, there has to be such an application somewhere

  3. If you have no control over the enduser’s environment and since you’re dealing with a web application, it’s up to the user to either download the file or view it in the browser via a plugin and print it themselves. You can’t force the user’s browser to print the file.

Best regards

Peter De Berdt

Where are you trying to print it? On the server or on the users PC? It is not possible, I think, to force a print on the users PC from a web app, the user must do that himself.

Colin

On the user's PC you can use javascript to trigger the printing (window.print) but, as Colin correctly notes, that will present the user with a printer dialog box, not automatically print the contents of the page. At any rate, that's not relevant until you get the pdf into the user's browser. To do that you'll probably use send_file which, iirc, will trigger a dialog that asks the user whether they want to save or print the file.

HTH, Bill

Bill Walton wrote: [...]

At any rate, that's not relevant until you get the pdf into the user's browser. To do that you'll probably use send_file which, iirc, will trigger a dialog that asks the user whether they want to save or print the file.

I think that would be browser-specific. Wouldn't send_file just make the browser act the same way it would when it received a static PDF file?

HTH, Bill

Best,

Yes it would. And 1) you're right - the options probably are browser-specific, and 2) the options I was thinking of are save or open, not save or print. And further, the javascript option wouldn't work either since the pdf would either replace what was in the window, open a new one, or open the file in Reader. My bad. Responding before caffeine kicks in is dangerous ;-(

Best regards, Bill

Bill Walton wrote:

Bill Walton wrote: [...]

At any rate, that's not relevant until you get the pdf into the user's browser. �To do that you'll probably use send_file which, iirc, will trigger a dialog that asks the user whether they want to save or print the file.

I think that would be browser-specific. �Wouldn't send_file just make the browser act the same way it would when it received a static PDF file?

Yes it would. And 1) you're right - the options probably are browser-specific, and 2) the options I was thinking of are save or open, not save or print. And further, the javascript option wouldn't work either since the pdf would either replace what was in the window, open a new one, or open the file in Reader. My bad. Responding before caffeine kicks in is dangerous ;-(

Understood. Next time wait till before the caffeine kicks in before posting to the list. :slight_smile:

Best regards, Bill

Best,