Hi all iText cracks, it seems that I have started an strategic discussion about the usage of PDFs and I appreciate the various comments. Fact is, the insurance company decided to create a PDF with statement of accounts, in Java with iText on IBM z/OS (Websphere XD). See requirements at the end of the mail. I have to implement the application and intent to apply best iText practice. Please let me know if you doubt that we succeed with the chosen approach (PDF file size, iText, ...).
Based on your comments I have redesigned the application (see below): only one FileOutputStream (step 3 for the final document), step 1 and 2 uses ByteArrayOutputStream. Step 3 uses PdfWriter and PdfImportedPage instead of PdfCopy (performance enhancements). The following fact influences my design: (I guess...) I have to stamp per statement of account (page x/y, first page of a statement has a different table background template as the followintg pages within the statement). My concern: how can I ensure that the templates for the first resp. further pages are only included ONCE in the final document ? Any help would be very appreciated. Thanks a lot for your support. Martin Step 1 (per statement: unstamped) Document document = new Document(); ByteArrayOutputStream baosUnstamped = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baosUmstamped); document.open(); PdfContentByte pdfContentByte = document.getDirectContent(); int numberOfColumns = ...; PdfPTable table = new PdfPTable(numberOfColumns); itextTable.writeSelectedRows(0, -1, ... , ... , pdfContextByte); document.close(); Step 2 (per statement: stamped) unstampedReader = new Reader(baosUmstamped.toByteArray()); ByteArrayOutputStream baosStamped = new ByteArrayOutputStream(); stamper = new PdfStamper(unstampedReader, baosStamped); int pageNum = ...; PdfContentByte underContent = stamper.getUnderContent(pageNum); PdfTemplate templateFirstPage = ...; PdfTemplate templateSecondPage = ...; /* for first page within statement of account */ underContentByte.addTemplate(templateFirstPage); /* for page two and upward within statement of account */ underContentByte.addTemplate(templateSecondPage); PdfContentByte overContent = stamper.getOverContent(pageNum); overContent.beginText(); overContent.setTextMatrix(... , ...); String pageText = ...; /* page x/y */ overContent.showText(pageText); overContent.endText(); Step 3 FileOutputStream fos = new FileOutputStream(...); Document finalDocument = new Document(); finalWriter = PdfWriter.getInstance(finalDocument, fos); /* per stamped statement */ stampedReader = new Reader(baosStamped.toByteArray()); int pageNum = ...; finalWriter.getImportPage(stampedReader, pageNum); /* for each stamped page */ Requirements PDF includes up to 3'500 statement of accounts, a statement of account can have up to 50 pages, we do not expect that the PDF has more than 20'000 pages. A typical batch-run creates a PDF with 3'500 statement of accounts with a maximum of 3 pages per statement of account. The parameters for the batch job are: range of account numbers, period, 2 - 4 variable table columns (fixed columns are: debit, credit, balance). The first page of the statement includes: page header with the address of the account owner, a table with 5 to 7 columns with a table header and 30 body rows. Page two and upward of the statement has no page header, layout of the table is equivalent to page one (table header), with 50 body rows. End of statement: empty row followed by a total row for debit, credit and balance. Each statement has its own page number in the footer (page x/y). The footer has a fix text (same content and position for all pages, independent of statement). Each odd table body row is gray underlayed ("table background"), including empty rows at the end of the table. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/