Be aware that silent printing won't work with the current updates to Adobe Reader 8 or later due to security concerns. (you wouldn't want to come to a web site and have your printer start spewing pornography or profanity, would you???)
Leonard -----Original Message----- From: nafota [mailto:[email protected]] Sent: Tuesday, March 29, 2011 1:24 AM To: [email protected] Subject: [iText-questions] Silent printing PDF I have read everywhere about the option of silent printing (printing a PDF document in client side )… I have implemented a silent printing servlet as follow: [code] public class EitPdfPrintServlet extends HttpServlet { private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ System.out.println("ProductionView.EitPdfPrintServlet: In print file Servlet processing print"); System.out.println(); String vDocFullPath=(String)(request.getSession().getAttribute("docFullPath")); response.setContentType("application/pdf"); PdfReader reader = new PdfReader(vDocFullPath); try { PdfStamper stamper = new PdfStamper(reader,response.getOutputStream()); PdfWriter writer = stamper.getWriter(); writer.addJavaScript("this.print({bUI: true, bSilent: true, bShrinkToFit: true});",false); writer.addJavaScript("this.closeDoc(true);"); stamper.close(); } catch (DocumentException de) { de.printStackTrace(); System.err.println("document: " + de.getMessage()); } } } [/code] The issue is I need to print few PDF'S files at once, when a user clicks a button in the server side I am merging all the pdf files into one file (I prefer to merge the files so the user won't need to approve printing for each PDF document), and then invoking the servlet form inside java code: [code] FacesContext context = FacesContext.getCurrentInstance(); EITServletUtils.mAddSessionParameter("docFullPath", vTargetFileToPrint); String javaScriptText = "window.open('./PrintPdfServlet','_blank');"; JavascriptContext.addJavascriptCall(context,javaScriptText); [/code] The problem is I can't figure out how to close the document in the browser after the document finish printing? It seems like the row writer.addJavaScript("this.closeDoc(true);"); Is useless! Off course I will be more satisfied if I can some how avoid from the user to view the pdf document! Hope to get some ideas, Thanks, Natalie -- View this message in context: http://itext-general.2136553.n4.nabble.com/Silent-printing-PDF-tp3414055p3414055.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
