PdfPTable can't be added to a Paragraph.
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, August 12, 2008 2:57 PM
> To: [email protected]
> Subject: [iText-questions] IndexOutOfBoundsException at
> Paragraph.add(Unknown Source)
>
> Hello,
>
> I am trying to add a header to my PDF, but get the following
> exception (source code see end of this mail:
>
> Exception in thread "PDF Creation"
> java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
> at java.util.ArrayList.RangeCheck(ArrayList.java:547)
> at java.util.ArrayList.get(ArrayList.java:322)
> at com.lowagie.text.Paragraph.add(Unknown Source) (...)
>
> I really don't know what exactly is causing this, does anyone
> have an idea? If I only add the first to paragraphs to my
> header it works, but the table does not! I'm thankful for any
> help or advice.
>
> Code:
> PdfPTable table = new PdfPTable(2);
> table.setWidthPercentage(100);
> table.setSpacingBefore(0);
> table.setSpacingAfter(0);
> table.getDefaultCell().setBorder(0);
> table.getDefaultCell().setNoWrap(true);
> Paragraph headerP = new Paragraph();
> Paragraph headerP2 = new Paragraph();
> headerP.add(new Paragraph("text1"), FONT1));
> headerP.add(new Paragraph("text2", FONT1));
> {
> PdfPCell cell = new
> PdfPCell(table.getDefaultCell());
>
> cell.setHorizontalAlignment(Element.ALIGN_LEFT);
> cell.setUseAscender(true);
> Paragraph leftP = new
> Paragraph("tabletext1", FONT2);
> leftP.setAlignment(Paragraph.ALIGN_LEFT);
> cell.addElement(leftP);
> table.addCell(cell);
> }
> {
> Paragraph rightP = new Paragraph();
> PdfPCell cell = new
> PdfPCell(table.getDefaultCell());
>
> cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
> cell.setUseAscender(true);
> rightP.setAlignment(Paragraph.ALIGN_RIGHT);
> rightP.add(new
> Paragraph("tabletext2.1", FONT2));
> rightP.add(new
> Paragraph("tabletext2.2", FONT2));
> rightP.add(new
> Paragraph("tabletext2.3, FONT2));
> cell.addElement(rightP);
> table.addCell(cell);
> }
> headerP2.add(table);
> headerP.add(headerP2);
> return headerP;
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php