Hi,
Requirement is , there is a thridparty application which reads multiple word
documents from a predefined input location and converts them in to one pdf
file and writes it to predefined output location location.
We need to read this pdf file and create a new pdf file and add page numbers
to all the pages of this pdf file.
We get an error - "Map failed" that gets printed in the output when the file
size is 200MB.
Code Snippet pasted below
public void execute(
String inputPdfName,
String outputDirName,
String outputPdfName,
BaseFont bf,
float fontSize
) throws Exception {
try {
Document document = null;
PdfReader reader = new PdfReader(inputPdfName);
int n = reader.getNumberOfPages();
PdfStamper stamp = new PdfStamper(reader, new
FileOutputStream(outputDirName + outputPdfName));
int i = 0;
PdfContentByte over;
float textSize = 0;
String strText = "";
float textBase = 0;
while (i < n) {
i++;
document = new Document(reader.getPageSizeWithRotation(i));
strText = i + "/" + n;
textSize = bf.getWidthPoint(strText, fontSize);
textBase = document.top();
over = stamp.getOverContent(i);
over.beginText();
over.setFontAndSize(bf,fontSize);
float adjust = bf.getWidthPoint("0", fontSize);
over.setTextMatrix(document.right() - textSize - adjust,
textBase);
over.showText(strText);
over.endText();
}
stamp.close();
document.close();
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
}
Does this code needs some tweaking to improve memory usage to avoid MAP
failed or OutofMemeory error????
Thanks
Saru
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/READ-WRITE-LARGE-FILE-200MB-MAP-failed-Error-tp3074067p3074067.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
iText-questions mailing list
[email protected]
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