Attached is a sample PDF.
Here is the java code I am using:

        public static void createPrintPDF(HttpServletRequest request,
                        HttpServletResponse response, List urlListReports, 
                        List urlListImages, boolean autoPrint,
                        String afterPrintURL)
                        throws Exception {
                Document document = new Document();
                PdfReader pdfReader = null;
                InputStream is = null;
                OutputStream os = response.getOutputStream();
                PdfWriter pdfWriter = PdfWriter.getInstance(document, os);
                pdfWriter.setPdfVersion(PdfWriter.PDF_VERSION_1_5);
                document.open();
                document.setPageSize(PageSize.LETTER);
                
                if(autoPrint){
                        PdfAction autoPrintingAction =
PdfAction.javaScript("this.print(true);",pdfWriter);
                        pdfWriter.setOpenAction(autoPrintingAction);
                }
                else {
                        pdfWriter.setOpenAction("");
                }
                if(afterPrintURL!=null && !"".equals(afterPrintURL)){
                        PdfAction donePrintingAction = 
PdfAction.javaScript("app.launchURL(\'" +
afterPrintURL + "\');",pdfWriter);
                        pdfWriter.setAdditionalAction(PdfName.DP, 
donePrintingAction);
                }
                PdfContentByte cb = pdfWriter.getDirectContent();
                for (String location : urlListReports) {
                        try {
                                is = getContent(location, request);
                                if (is != null) logger.debug(is.toString());
                                pdfReader = new PdfReader(is);
                                for (int x = 1; x < 
pdfReader.getNumberOfPages()+1; x++) {
                                        
document.setPageSize(pdfReader.getPageSizeWithRotation(x)); 
                                        document.newPage();
                                        PdfImportedPage pip = 
pdfWriter.getImportedPage(pdfReader, x);
                                        cb.addTemplate(pip,0,0);                
                                                                
                                }
                        }
                        catch (Exception e){
                                logger.error("EXCEPTION - CreatePrintPDF", e);
                        }
                        finally {
                        if (is != null) is.close();
                        }
                        
                }
http://itext-general.2136553.n4.nabble.com/file/n3447897/sampleLetter.pdf
sampleLetter.pdf 

--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Having-problem-with-done-printing-action-tp3445396p3447897.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now!  http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
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

Reply via email to