I have a web application that has a requirement to silent print a generated pdf (the user should not even see the pdf). I tried basing my code on the sample code from the iText site:
// setting some response headers response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); // setting the content type response.setContentType("application/pdf"); // the content length is needed for MSIE!!! response.setContentLength(baos.size());
The code you posted doesn't print anything - it streams a PDF file to a browser. That the file contains code to print it under certain circumstances is irrelevant. A few things to consider in this situation:
Without opening the file there's no chance of it being printed, since the embedded print code depends on the file being opened.
Whether the file is opened is not under the control of the web app. The user may have set the browser to save PDF files w/o opening them.
If it is opened, it will be displayed. No way around that, at least not with common viewers like Adobe Reader or OS X Preview.
Given these, I think what you're trying to achieve is not possible. I'd argue that's a good thing, too, since printing something on a client system w/o the user noticing it is not a nice thing to do. Maybe in your situation it's acceptable or even desirable, but in general it's not, which is why it doesn't work that way.
What is the rationale for wanting to do this? [ April 03, 2008: Message edited by: Ulf Dittmer ]
Ping & DNS - updated with new look and Ping home screen widget
Joined: Feb 06, 2004
Thanks for the response.
What my users are really looking for is the ability to generate a pdf and silent print without opening the pdf at all. This is a requirement because the users do not want duplicates of a pdf printed.
I am also interested in silent printing with iText.
However I did not find any solution.
Do you have any idea?
Joined: Mar 22, 2005
Re-read my previous post. Being able to print something without asking the user for permission is a risk in several ways; that's why it's not possible.
Joined: Mar 26, 2010
Ulf Dittmer wrote:Re-read my previous post. Being able to print something without asking the user for permission is a risk in several ways; that's why it's not possible.
There a guy who confirms that he can do slient printing with iText.
That's why I am trying to repeat what he have been able to do.