Hi,
Per Bruno's
http://www.nabble.com/PdfStamper-vs-PdfCopy-tf3685313.html#a10301433 advice
I used PdfSmartCopy following his example and after about 60 pages it throws
a Java Heap out of memory. I'm trying to do this for potentiall 20 thousand,
so just increasing my memory I don't think is going to be an option. Is
there an alternative method that's not goign to kill my server's memory?
spefically this is what I'm doing
PdfReader reader;
ByteArrayOutputStream baos;
PdfStamper stamper;
AcroFields form;
Document document = new Document();
try {
PdfSmartCopy copy = new PdfSmartCopy(document, new
FileOutputStream("EIDForms.pdf"));
document.open();
for (int i = 0; i < values.length; i++) {
// set fields
reader = new PdfReader("EIDFormTemplate.pdf");
baos = new ByteArrayOutputStream();
stamper = new PdfStamper(reader, baos);
form = stamper.getAcroFields();
form.setExtraMargin(0, 1);
for (int j = 0; j < keys.length; j++) {
form.setField(keys[j], values[i][j]);
}
stamper.setFormFlattening(true);
stamper.close();
// add page
reader = new PdfReader(baos.toByteArray());
copy.addPage(copy.getImportedPage(reader, 1));
}
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
--
View this message in context:
http://www.nabble.com/Heap-out-of-memory---PdfSmartCopy%28%29-tf3726501.html#a10428999
Sent from the iText - General mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/