Thank you for your answers but I still have the problem when I have to change all the pages within the document and I think there's nothing to do in this case because using RandomAccessFileOrArray uses less memory but it takes 4 times more than using standard PDFReader in this case.
I have another service which simply adds a page to the end of the PDF file. I assume that in this case I don't need to load the entire PDF file using PDFReader, therefore RandomAccessFileOrArray should be useful in this case. The following code : final ByteArrayOutputStream fos = new ByteArrayOutputStream(); PdfStamper stamp = new PdfStamper(new PdfReader(new RandomAccessFileOrArray(pdfBytes), null), fos); Image img = getImage(); final Rectangle rect = reader.getPageSize(1); stamp.insertPage(n + 1, rect); img.setAbsolutePosition(rect.getWidth() - img.getWidth(), rect.getHeight() - img.getHeight()); final PdfContentByte overContent = stamp.getOverContent(n + 1); overContent.addImage(img); stamp.close(); return fos.toByteArray(); My profiling says that it is more or less the same using RandomAccessFileOrArray (in fact is worse regarding time) or the standard PDFReader in this case. Shouldn't this be more memory efficient than using PDFReader the standard way? Best regards, Sérgio Silva
------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________ 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
