I think I see the problem our friend is talking about. When using the SAXiTextHandler to parse an XML file into PDF, some table structures trigger an exception similar to the one he lists.
I've pasted and attached a test case class and input file so you can
reproduce the bug locally. Running these gives me the following
exception against a source build of itext-1.4.jar (the binary build
gives an identical trace, minus the line numbers):
------------- iTextTableBugTest.java
import java.io.InputStream;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.xml.SAXiTextHandler;
public class iTextTableBugTest {
public static void main(String[] argv) throws Exception {
InputStream xmlStream =
iTextTableBugTest.class.getResourceAsStream ("/iTextTableBug.xml");
Document document = new Document();
PdfWriter pdfwriter = PdfWriter.getInstance(document, System.out);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new InputSource(xmlStream),new SAXiTextHandler(document));
}
}
------------- iTextTableBug.xml
<?xml version="1.0" encoding="UTF-8" ?>
<itext producer="Juan">
<table columns="2" width="95%" widths="50;50">
<row>
<cell>
<table columns="2" width="100%" widths="1;5;">
<row><cell colspan="2">a1</cell></row>
<row><cell colspan="2">a2</cell></row>
<row><cell colspan="2">a3</cell></row>
</table>
</cell>
<cell>b1</cell>
</row>
</table>
<newpage/>
</itext>
------------- Output:
ExceptionConverter: DocumentException:
java.lang.IndexOutOfBoundsException: Index: 6, Size: 6
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at com.lowagie.text.pdf.PdfDocument.extractRows(PdfDocument.java:1504)
at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:1219)
at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:2014)
at com.lowagie.text.Document.add(Document.java:281)
at
com.lowagie.text.xml.SAXiTextHandler.handleEndingTags(SAXiTextHandler.java:759)
at
com.lowagie.text.xml.SAXiTextHandler.endElement(SAXiTextHandler.java:671)
at
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:579)
at
org.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:646)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:1972)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:878)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.handleEndElement(XMLDocumentFragmentScannerImpl.java:1144)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:987)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1445)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:524)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1169)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at iTextTableBugTest.main(iTextTableBugTest.java:24)
Exception in thread "main"
-John
iTextTableBugTest.java
Description: Binary data
<?xml version="1.0" encoding="UTF-8" ?> <itext producer="Juan"> <table columns="2" width="95%" widths="50;50"> <row> <cell> <table columns="2" width="100%" widths="1;5;"> <row><cell colspan="2">a1</cell></row> <row><cell colspan="2">a2</cell></row> <row><cell colspan="2">a3</cell></row> </table> </cell> <cell>b1</cell> </row> </table> <newpage/> </itext>
------------------------------------------------------------------------- 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
