The lines:
content.toPdf(writer);
content = writer.getDirectContent();
don't do anything.
You need more memory assigned to the JVM.
Best Regards,
Paulo Soares
----- Original Message -----
From: "Jeykumar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 29, 2002 6:31
Subject: [iText-questions] Help - Out of Memory Error..
> Hi All,
> Iam new to use this wonderful iText PDF Library. I have
> written a simple class that exports the
> java.awt.print.Book object to pdf. This is done by creating a
> pdfTemplate and getting the graphics of the template
> and i paint the pages in Book to this template. For every page in the
> Book, i create a pdfTemplate and append it to the pdfDocument.
> Here is the code snippet.
>
> ......
> Document pdfDocument = new Document();
> FileOutputStream outputFile = new
> FileOutputStream(fileName);
> PdfWriter writer =
> PdfWriter.getInstance(pdfDocument, outputFile);
> PdfContentByte content = writer.getDirectContent();
> PdfTemplate template = null;
> Graphics2D g2d = null;
> Printable page = null;
> PageFormat pageformat = null;
> int pageWidth = 0;
> int pageHeight = 0;
> // m_printDocument is (java.awt.print.Book)
> int numPages = m_printDocument.getNumberOfPages();
> for (int pageCount = 0; pageCount < numPages;
> pageCount++) {
> page = m_printDocument.getPrintable(pageCount);
> // we create a template and a Graphics2D object
> that
> // corresponds with it
> pageformat =
> m_printDocument.getPageFormat(pageCount);
> pageWidth = (int) pageformat.getWidth();
> pageHeight = (int) pageformat.getHeight();
> template = content.createTemplate(pageWidth,
> pageHeight);
> template.setWidth(pageWidth);
> template.setHeight(pageHeight);
> g2d = template.createGraphics(pageWidth,
> pageHeight, mapper);
> page.print(g2d, pageformat, 0);
> if (pageformat.getOrientation() ==
> PageFormat.LANDSCAPE) {
> content.addTemplate(template, 0, 1, -1, 0,
> pageHeight, 0);
> } else {
> content.addTemplate(template, 0, 0);
> }
> status.setStatusText("Writing Page " + pageCount
> + " of " + numPages );
> if (!status.isVisible()) {
> status.setVisible(true);
> }
> content.toPdf(writer);
> content = writer.getDirectContent();
> pdfDocument.newPage();
> }
> status.setStatusText("Completed Exporting to PDF.");
> status.enableOkButton();
> pdfDocument.close();
>
> ......
> The above code works fine when the number of pages is less in the Book.
> The problem is it throws out of memory error when the number of pages
> in Book are huge like 390.
> Please anyone help me in fixing the error.
>
> reg.
> Jeykumar
>
>
>
>
> ------------------------------------------------------- This sf.net
> email is sponsored by:ThinkGeek Welcome to geek heaven.
> http://thinkgeek.com/sf _______________________________________________
> iText-questions mailing list [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions