Works for me. It's better to post standalone code to reproduce the problem 
rather than a code fragment.

Paulo

----- Original Message ----- 
From: "Webber, David (NIH/OD) [C]" <[EMAIL PROTECTED]>
To: "Post all your questions about iText here" 
<[email protected]>
Sent: Tuesday, August 01, 2006 4:43 PM
Subject: [iText-questions] Stack overflow error using iText


> Folks - finally been able to isolate this issue with two samples:
>
> http://www.drrw.net/temp/iText/stackoverflow-sample1.pdf
>
> http://www.drrw.net/temp/iText/stackoverflow-sample2.pdf
>
> When we attempt to run them through iText we get the "stack overflow"
> error occurring.
>
> Here's the code fragment of how we are using iText, and here's also the
> java log details of the loop that leads to the stack overflow crash.
>
> Thanks, DW
>
> ========================================================================
> ===
>
> private void addReaderData(com.lowagie.text.Document pdfDocument,
>
>                                    PdfReader reader, PdfWriter writer,
> String bookmarkText, String attachmentName) throws Throwable {
>
>                        int i = 0;
>
>                        PDFGenerationThrowable pth=null;
>
>                        MessageCollection messages = new
> MessageCollection();
>
>                        try {
>
>                                    int n = reader.getNumberOfPages();
>
>
>                                    PdfContentByte cb =
> writer.getDirectContent();
>
>
>
>                                    while (i < n) {
>
>                                                i++;
>
>                                                cat.debug("Add Reader
> Data Page # "+i+ attachmentName);
>
>
> pdfDocument.setPageSize(reader.getPageSizeWithRotation(i));
>
>                                                pdfDocument.newPage();
>
>                                                // pdfDocument.add(new
> Paragraph("This is a test"));
>
>                                                PdfImportedPage page =
> writer.getImportedPage(reader, i);
>
>                                                int rotation =
> reader.getPageRotation(i);
>
>
>
>                                                cat.debug("HEIGHT = "
>
>
> + reader.getPageSizeWithRotation(i).height());
>
>
>
>                                                if (rotation == 90 ||
> rotation == 270) {
>
>
> cb.addTemplate(page, 0, -1f, 1f, 0, 0, reader
>
>
> .getPageSizeWithRotation(i).height());
>
>                                                } else {
>
>
> cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
>
>                                                }
>
>                                                //
> pdfDocument.setFooter(pageFooter);
>
>                                    } // end while
>
>                        }catch(Exception e)
>
>                        {
>
>                                    cat.debug("Exception in
> addReaderData method while PDF Rotation", e);
>
>                                    throw e;
>
>                        }
>
>                        catch(StackOverflowError sth)
>
>                        {
>
>                                    cat.debug("Stack over Flow error in
> addReaderData method while PDF Rotation", sth);
>
>                                    ArrayList tokens = new ArrayList();
>
>                                    tokens.add(new Integer(i));
>
>
> tokens.add(bookmarkText+"{"+attachmentName+"}");
>
>                                    pdfErrors.add(new
> Message(MessageKeys.EGRANTS_INVALID_PDF_STACK_OVER_FLOW_ERROR, tokens));
>
>
>                        } catch (Throwable th) {
>
>                                     cat.debug("Exception in
> addReaderData method while PDF Rotation",th);
>
>                                    //throw new
> StackOverFlowException(i,bookmarkText,new Exception());
>
>                                     throw th;
>
>                        }
>
>            } // addReaderData()
>
> ==============================================
> Log details:
>
> 2006-08-01 11:36:57,107 DEBUG Task-0
> gov.nih.egrants.beantier.processor.EgrantsFE - [GRANT00072741] - Stack
> over Flow error in addReaderData method while PDF Rotation
>
> java.lang.StackOverflowError
>
>            at
> com.lowagie.text.pdf.BaseFont.getBaseName(BaseFont.java:421)
>
>            at
> com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:360)
>
>            at
> com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:332)
>
>            at
> com.lowagie.text.Font.getCalculatedBaseFont(Font.java:718)
>
>            at com.lowagie.text.pdf.PdfChunk.<init>(PdfChunk.java:203)
>
>            at
> com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:1328)
>
>            at com.lowagie.text.Phrase.process(Phrase.java:299)
>
>            at
> com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:1478)
>
>            at
> com.lowagie.text.pdf.PdfDocument.initPage(PdfDocument.java:1935)
>
>            at
> com.lowagie.text.pdf.PdfDocument.newPage(PdfDocument.java:812)
>
>            at
> com.lowagie.text.pdf.PdfDocument.carriageReturn(PdfDocument.java:2071)
>
>            at
> com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:1333)
>
>            at com.lowagie.text.Phrase.process(Phrase.java:299)
>
>            at
> com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:1478)
>
>            at
> com.lowagie.text.pdf.PdfDocument.initPage(PdfDocument.java:1935)
>
>            at
> com.lowagie.text.pdf.PdfDocument.newPage(PdfDocument.java:812)
>
>            at
> com.lowagie.text.pdf.PdfDocument.carriageReturn(PdfDocument.java:2071)
>
>            at
> com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:1333)
>
>            at com.lowagie.text.Phrase.process(Phrase.java:299)
>
>
> and sequence loops until stack overflows...
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share 
> your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to