This method of silent printing has been disallowed by Acrobat/Reader 8.1.1 and later. You will need to present the print dialog.
Leonard On Apr 10, 2008, at 9:07 PM, Jonathan Richard wrote: > Hi > > I am using iText in a servlet to generate pdf and the silently > print this pdf in my web application. > > I call the servlet in a 1x1px iframe when clicking on the print > button. The javascript in the pdf is then executed and the it is > printed directly to the user's default printer without displaying > the print preferences window. > > The tricky part is that I need to print on a specific paper size: > A6. (about 4x6 inch) > > When generating the PDF, I use A6 as format: > > Document document = new Document(PageSize.A6, 0, 0, 20, 30); > > And, using the writer I add the JavaScript code to silently trigger > the print: > > String js = ""; > js += "var pp = this.getPrintParams();\r\n"; > js += "pp.interactive = pp.constants.interactionLevel.silent;\r\n"; > js += "pp.colorOverride = pp.constants.colorOverrides.gray;\r\n"; > js += "var fv = pp.constants.flagValues;\r\n"; > js += "pp.flags = pp.flags | fv.setPageSize;\r\n"; > js += "this.print(pp);" + "\r\n" + "this.closeDoc();\r\n"; > writer.addJavaScript(js); > > On the HP LaserJet 1200 I got here, it works just fine. The printer > ajust the printing based on the paper size specified in the PDF > Document Object. > On a HP DeskJet 6840 it refuses to print. I can clearly see (in > Windows) request sent to the printer is of size: LETTER, 8.5x11. > Which is the default paper size of the printer. > > The printer will pull of piece of paper from the tray and then > check the size with a laser. Since it is not the proper size, it > will freeze and send an error. > > If I set the default paper size by hand to 4x6 inch in the printing > preferences it will work just fine. It works, but I want to avoid > to have to set manually the default printing size for 2 reasons: > - There is over 50 offices using this web application spread across > different cities, cofiguring them would be ... well... complicated. > - People might use these printers for other paper size. > > I don't understand why the flag is not taken in consideration. > > Has anyone got through this kind of problem? Is there any other > properties I could use to force the printer to print that PDF? > > Jonathan > > > > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save > $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http:// > java.sun.com/javaone_______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Do you like iText? > Buy the iText book: http://www.1t3xt.com/docs/book.php > Or leave a tip: https://tipit.to/itexttipjar ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar
