You can try caching the imported page in memory. If the number of templates is small the memory overhead will be managable. Is the template large? In that case you can also try to re-create the template. When I create PDF:s using a simple template combined with data from the database I have creation times of around 0.2 seconds (including the database call), so 2 seconds seems a lot.
/Klas > ----- Original Message ----- > From: "Kruzic, Alex x55204" <[email protected]> > To: <[email protected]> > Sent: Friday, May 01, 2009 2:54 PM > Subject: [iText-questions] Imported pages are too slow > > It seems that that line 3 below is very slow. On average it takes 2 seconds > to run. My app needs to generate 11,000 PDF's and with this code below, it > takes over a day! > > Now if I comment out line 3, it finishes in 7 minutes. Big, big difference. > Does anyone know why this code is so slow, and even more importantly, is > there a way to do this better. > > Thanks. > > Alex > > PdfImportedPage page = null; > PdfContentByte cb = PDFwriter.getDirectContent(); > page = PDFwriter.getImportedPage(PDFreader, iPages); > cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0); > ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ iText-questions mailing list [email protected] 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/
