Dear iText developers,
I have noticed that for certain (perhaps not well-formed) PDFs following
exceptions are thrown:
* NumberFormatException in PdfNumber
java.lang.RuntimeException: - is not a valid number -
java.lang.NumberFormatException: For input string: "-"
at com.itextpdf.text.pdf.PdfNumber.<init>(PdfNumber.java:83)
at
com.itextpdf.text.pdf.PdfContentParser.readPRObject(PdfContentParser.java:180)
at
com.itextpdf.text.pdf.PdfContentParser.parse(PdfContentParser.java:89)
at
com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.processContent(PdfContentStreamProcessor.java:359)
at
com.itextpdf.text.pdf.parser.PdfReaderContentParser.processContent(PdfReaderContentParser.java:41)
It looks like there should be an additional check in PdfNumber that
input string is actually a number and perhaps ignore it in case it
is not.
* StringIndexOutOfBoundsException in SimpleTextExtractionStrategy
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:686)
at
com.itextpdf.text.pdf.parser.SimpleTextExtractionStrategy.renderText(SimpleTextExtractionStrategy.java:126)
at
com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.displayPdfString(PdfContentStreamProcessor.java:304)
at
com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.access$2500(PdfContentStreamProcessor.java:75)
at
com.itextpdf.text.pdf.parser.PdfContentStreamProcessor$ShowTextArray.invoke(PdfContentStreamProcessor.java:428)
at
com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.invokeOperator(PdfContentStreamProcessor.java:247)
at
com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.processContent(PdfContentStreamProcessor.java:366)
at
com.itextpdf.text.pdf.parser.PdfReaderContentParser.processContent(PdfReaderContentParser.java:41)
Additional check for string length is required or perhaps
StringUtils.substring(renderInfo.getText(), 0, 1) will be safe enough.
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
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