In
order to print a PDF document the adobe needs to open the PDF. as far as I
know you cannot print PDF document without opening. I have found that
some versions of Adobe plugins stay open even after printing so I added
additional _javascript_ to close the document after printing.
Below
is code sample that includes closing the document after printing. so
virtually to users it appears as if the document never
opened.
Document document = new Document();
FileOutputStream fos = new FileOutputStream("SilentPrint.pdf");
try {
PdfWriter writer = PdfWriter.getInstance(document, fos);
document.open();
FileOutputStream fos = new FileOutputStream("SilentPrint.pdf");
try {
PdfWriter writer = PdfWriter.getInstance(document, fos);
document.open();
write.addJavaScript("this.print({bUI: false, bSilent: true,
bShrinkToFit: true});",false);
write.addJavaScript("this.closeDoc();");
document.add(new Chunk("Silent Auto Print"));
document.close();
} catch (DocumentException e) {
e.printStackTrace();
}
document.add(new Chunk("Silent Auto Print"));
document.close();
} catch (DocumentException e) {
e.printStackTrace();
}
hope
this helps
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Swati das
Sent: Monday, May 08, 2006 6:46 PM
To: [email protected]
Subject: Re: AW: [iText-questions] Silent Printing of PDFI too need to print the pdf w/o opening.The _javascript_ requires the pdf to be opened in order to print it.Can I avoid that??
"Bernd, Juergen" <[EMAIL PROTECTED]> wrote:The SilentPrintServlet uses _javascript_ to print the PDF, but the PDF is still displayed using the acrobat reader browser plugin.Is there anyway to prevent this, so that is a real hidden print, and the browser displays no PDF but anotherHTML page?-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]Im Auftrag von Swati das
Gesendet: Samstag, 6. Mai 2006 04:46
An: [email protected]
Betreff: RE: [iText-questions] Silent Printing of PDFThanks, pls can you send me the exact link or the source code.I had searched for it but could not get anything.There is one example called java.com.lowagie.examples.general.webapp.SilentPrintServletbut that doesnt seem to work. Are you talking about the same one??
Sreenaresh Gopu <[EMAIL PROTECTED]> wrote:You can silent print PDF from Java code. I implemented it recently and it works great. go an take a look at the example on itext web site there is an example how to implement silent print. basically you will be writing _javascript_ for PDF when creating the PDF using ITEXT.-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Swati das
Sent: Friday, May 05, 2006 2:49 PM
To: [email protected]
Subject: Re: [iText-questions] Silent Printing of PDFThanks for your response.Actually I need to send this print through the Java code. Can I execute lpr though Java?
Udo Rader <[EMAIL PROTECTED]> wrote:On Fri, 2006-05-05 at 13:58 -0700, Swati das wrote:
> Hi,
>
> Can I print a PDF directly to the printer using iText?
no, iText is a library to produce, parse and manipulate PDF documents.
> All that I know of, is to open the Adobe Reader and execute a print
> command , which I want to avoid.
>
> I just want my pdf to get directly printed on the printer without
> opening the reader.
depending on your OS, this might work:
% lpr thedocument.pdf
but you need to be more specific about your environment.
Udo Rader
--
BestSolution.at EDV Systemhaus GmbH
http://www.bestsolution.at
Blab-away for as little as 1¢/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice.
Yahoo! Mail goes everywhere you do. Get it on your phone.
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
