aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to print a document? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to print a document?" Watch "How to print a document?" New topic
Author

How to print a document?

Adithya Rayaprolu
Ranch Hand

Joined: Jun 19, 2001
Posts: 137
Hi,
We have a table, each row in that table, describes about a report, means if we have 10 reports, we have 10 rows in this table and each row describes the report. In one of the cells we have a 'Print' button, when we click this button, it prints the corresponding document, this document needs to be downloaded by the client. We should not open the actual document in a new window. How can we do this?
Thanks a lot in advance.
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
I've seen this avoided by using a "print frame" - a frame that doesn't display, but is part of the page. When the user clicks a print button in the main page (really a main frame), it opens a print page in the print frame and prints it onload. It's very tidy, for printing something other than what the user is viewing.
hth,
g.
Adithya Rayaprolu
Ranch Hand

Joined: Jun 19, 2001
Posts: 137
Hi Garann,
Thanks a lot for the reply. I included an invisible iframe in the document and I am able to print a single document using iframeid.print().
We need to print more than one document at a time. Is it possible to print more than 1 document at a time, without showing the print dialog more than once? In our screen, user can select as many reports as he wants and presses one button for printing all the reports he selected. I included the iframeid.print() in a for loop, but its not printing, its not at all showing the print dialog.
But if I include an alert box like this:
for(condition) {
alert("before printing");
iframeid.print();
}
its showing print dialog on each and every iteration. Is there anything that I can do to overcome this? We need to be able to print more than one document at a time without showing the print dialog more than once.
Thanks a lot once again in advance.
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
I'm pretty sure you're going to have to show the print dialog every time you try to send something to the printer. Sorry..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to print a document?