aspose file tools*
The moose likes Java in General and the fly likes How to Print Document without opening document? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to Print Document without opening document?" Watch "How to Print Document without opening document?" New topic
Author

How to Print Document without opening document?

Amol Chavan
Greenhorn

Joined: Sep 04, 2005
Posts: 28
Hi All,

Here is one more problem I'm facing.
Actually requirement is such to print the document without opening that document.
How to do it using java?
I have one jsp which has button 'Print Report' on clicking of which reports are geneated and it is also on sepaerate server for which I have link through I can connect over there and display these reports.
But now these reports should not be displayed in stead on click of this button these all reports should get printed and before printing it should ask user confirmation to print erport as wll aprinter selection.
The later part of asking user confirmation and selecting printer can be done using javascript but what about printing document on clicking button without even opening the document in brower.(All are web-based here).

Please help me asap.


Thanks n Regards,<br />Amol
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
When you click on the button, after confirmation and printer selection, the button does a doPost to the servlet which then prints all the available reports.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Amol Chavan
Greenhorn

Joined: Sep 04, 2005
Posts: 28
Thanks for reply,

But I cannot find any solution over there.
Actually I implemented some of the code sample that it has but of no use.
Can you give me any code sample which will generate a pop-up for selection of printer and confirmation of user.
This code is taking default service on network.
About which servlet you were talikng I cannot find any one at the link mentioned by you.

Please tell me if any code sample is there?
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Something will ALWAYS have to open the file or how would it know what to print?

Apart from that, what you're asking has more to do with html and Javascript than Java. Better ask in fora related to that.


42
Amol Chavan
Greenhorn

Joined: Sep 04, 2005
Posts: 28
HI,

Now I am able to select printer but not able to print contents of the file.
Can anyone tell me how to print a file/report using java print api.
I used all kind of DocFlavors but it did not work.

Also I want to print contents of report which is lying on defferent server for which I will have a link with me (URL).
Can anybody tell me how to bring contents from that URL and write to a temporary file and then print out contents of this file without displaying it to user.
Or is there any way to print the contents of that URL directly to printer without displaying it to user.

Thanks in advance.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

You should contact the people who gave you the requirement "print the document without opening that document" and let them explain what exactly they mean with this. What does "opening the document" mean to them? For example, is it a Word document, and by "without opening the document" do they mean that it should not open Microsoft Word?

In what format are your documents - HTML, PDF, DOC, ...?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Amol Chavan
Greenhorn

Joined: Sep 04, 2005
Posts: 28
Hi all,

Instead of giving such replies please prvovide me some solution.
Java Print APIs are helpful for this and I'm using the same but the problem is DocFlavor that I used is not able to match with the printer's requirement.So I used DocFlavor (http://java.sun.com/j2se/1.5.0/docs/api/) as Printable but it did not work.
Can anybody tell me is there any way to pick up files and put it into printer's printing queue? Is there any opensource in java available for this?

Please reply asap.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Print Document without opening document?
 
Similar Threads
How to print a document?
Printing through browser in Netscape 6 of HTML doc.
javax.print PDF problem / complex solution?
printing from an applet toolbar the image displayed in the applet via a thread
Is any way We can tell JSF to not response