Hi, I'm using iText 5.0.3 to encrypt an existing PDF (of size 10mb) using the PDFStamper.setEncryption() method but it takes more than 100mb of of memory. Basically I want the document permission to be set to PRINT only.
Normally I use the RandomAccessFileOrArray for the PdfReader and PDFStamper with append = true to modify PDF contents so that it takes less memory. But in the case of encryption I can't use append=true and hence I'm forced to not use RandomAccessFileOrArray for my PdfReader. Because if I use append=false and RandomAccessFileOrArray for PdfReader then it takes more than 5 minutes to do the encryption, whereas if I don't use RandomAccessFileOrArray then it consumes 100mb of memory for encrypting a 10mb file and 250mb for a 45mb file. Can something be done better to reduce the memory consumption with append=false? Pls find my code below. private void encrypt(String src, String dest) { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest)); PdfReader reader = new PdfReader(src, null); PdfStamper stamper = new PdfStamper(reader, bos, '\0', false); stamper.setEncryption(null, null, PdfWriter.ALLOW_PRINTING, true); stamper.close(); reader.close(); bos.close(); } Thanks Srinivaas -- View this message in context: http://itext-general.2136553.n4.nabble.com/PDFStamper-consuming-more-memory-tp3312356p3312356.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions 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