When using PDFStamper I am getting the error below. The OS is Windows 2003
and I have expanded the Java Max Heap size from 128mb to 512mb, but that
doesn't seem to make a difference. There is plenty of HD space available.
It seems to stamp the pages ok, but always errors during the
"stamper.close()" line. The code works for smaller documents, but does not
work for a 700 page document that is just over 2mb. Other iText classes
and methods work fine for this document.
java.io.IOException: Not enough storage is available to process this
command
at
sun.nio.ch.FileChannelImpl.map0(Native Method)
at
sun.nio.ch.FileChannelImpl.map (
FileChannelImpl.java:737)
at
com.lowagie.text.pdf.MappedRandomAccessFile.init(Unknown Source)
at com.lowagie.text.pdf.MappedRandomAccessFile.<init>(Unknown Source)
at
com.lowagie.text.pdf.RandomAccessFileOrArray.reOpen(Unknown
Source)
at
com.lowagie.text.pdf.PdfReader.getStreamBytesRaw(Unknown Source)
at
com.lowagie.text.pdf.PRStream.toPdf(Unknown Source)
at
com.lowagie.text.pdf.PdfIndirectObject.writeTo(Unknown Source)
at
com.lowagie.text.pdf.PdfWriter$PdfBody.add(Unknown Source)
at
com.lowagie.text.pdf.PdfWriter.addToBody(Unknown Source)
at
com.lowagie.text.pdf.PdfStamperImp.close(Unknown Source)
at
com.lowagie.text.pdf.PdfStamper.close(Unknown Source)
at JavaAgent.numberPages(JavaAgent.java:832)
at JavaAgent.processFinal(JavaAgent.java:652)
at JavaAgent.NotesMain(JavaAgent.java:381)
Code
outputfile = new File(filename);
// we create a PdfReader object
reader = new PdfReader(inputfilename);
os = new FileOutputStream(outputfile);
stamper = new PdfStamper(reader, os);
// we create an Image we'll use as a Watermark
Image img = Image.getInstance("../logo_small.gif");
img.scalePercent(50);
img.setAbsolutePosition(reader.getPageSizeWithRotation(1).getWidth()-60,reader.getPageSizeWithRotation(1).getHeight()-30)
;
// these are the canvases we are going to use
PdfContentByte over;
int total = reader.getNumberOfPages();
if (debug) System.out.println("Total pages : "+total);
for (int i = 1; i < total + 1; i++) {
if (debug) System.out.println("Stamping page :
"+i);
over = stamper.getOverContent(i);
over.addImage(img);
// Header
if (!dbTitle.equals(""))
ColumnText.showTextAligned(over, Element.ALIGN_CENTER, new Phrase(new
Chunk("Title: " + dbTitle, new Font(Font.HELVETICA, 10, Font.NORMAL))),
reader.getPageSizeWithRotation(1).getWidth() / 2,
reader.getPageSizeWithRotation(1).getHeight() - 15, 0);
// Page numbers
over.beginText();
over.setFontAndSize(bf, 10);
over.setTextMatrix(30, 15);
over.showText("page " + i + " of "+ total);
over.endText();
}
stamper.close();
Thanks,
Steve Senneff
Technology Specialist - Systems Design and Development
AIG Corporate Systems, Domino Web Development
steve_senneff@(protected)
-------------------------------------------------------------------------
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
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/