• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing at Client Side via MVC program  RSS feed

 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salaam,

We are having one Java program which uses Java Print API, in addition to Jasper's iReport api for generating reports and printing it.

The program is called through Servlet while user clicks on the link.

This works fine, if we have installed Printer at Server side.

But, the question is how do we make it possible to do the printing at Client's Printer.

Have came to know about window.print(Javascript). But the problem is that,we dont want to print entire page.
We just want to print particular data (which we are storing in ArraList object).
Since, the data is confidential, we don't want to show it on browser also( either on load or on popup windows).

Anyone, can help to achieve the same ?

We have used the following stuff:
Java Print Service API (javax.print.*)
Jasper Reports API (net.sf.jasperreports.*)



---------------------

Regards

Baseet Ahmed

I am Momin InshaAllah
---------------------
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I was last faced with a problem like this, I thought to use Windows print sharing to expose the client printer to the network, then install the client printer on the server. The server could then print to the client printer as if it were directly attached. The project was canceled before I implemented it so I can't say how well that approach would work or if there are any other alternatives.
One concern I'd have is printing confidential data on a printer that could be unsupervised when the print occurs, but you have to address that concern according to your environment.
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,

The problem with approach mentioned by you(install the client printer on the server),is not possible(due to some security policy).
Hence we cannot go into that track.

The data contains password-like info which we don't want to show on the screen.Hence could not go for window.print(which prints current window box data).

Any other alternatives...

---------------------

Regards

Baseet Ahmed

I am Momin InshaAllah
---------------------
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only things that comes to my mind is using an Applet.
 
Guido Sautter
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can applets access a local printer? Doubt it since this would be a point of attack, wouldn't it? If you have a client application, you might include some component that fetches the data and prints it, however. But this would have to be proof against others trying to fetch the same sensitive data unpermittedly.
 
Paul Clapham
Sheriff
Posts: 22827
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about using CSS to control that? I know you can use a "@media print" style with "display: none" to specify which elements should not appear in printed versions of the page. There's also the "@media screen" style, so probably you could make things invisible on the screen but visible in printed versions.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Guido Sautter:
Can applets access a local printer? Doubt it since this would be a point of attack, wouldn't it?


It can if it is signed.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Clapham:
How about using CSS to control that? I know you can use a "@media print" style with "display: none" to specify which elements should not appear in printed versions of the page. There's also the "@media screen" style, so probably you could make things invisible on the screen but visible in printed versions.


That's a good idea. It still would allow the user to get the values on screen by looking at the page's source code, but depending on the scenario that might well be an acceptable risk.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!