• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Print Document without opening document?

 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15356
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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, ...?
 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic