tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Klemens Dickbauer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TIKA-2919) NullPointerException when parsing PDF with OCR and ToXMLContentHandler
Date Fri, 02 Aug 2019 12:48:00 GMT

    [ https://issues.apache.org/jira/browse/TIKA-2919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16898863#comment-16898863

Klemens Dickbauer commented on TIKA-2919:

Thanx for the quick response!

Embarassing for me - i just typed the rough design of subclassing the handler for some extra
file writing. I double-checked if i really had called the super class startElement and endElement
methods and really, in this scenario with the two divs there was an error on my side, i didn't
call the second startElement method because it had the same name as its parent. Fixed it and
the NPE vanished. Sorry for the premature report. Will close now.

> NullPointerException when parsing PDF with OCR and ToXMLContentHandler
> ----------------------------------------------------------------------
>                 Key: TIKA-2919
>                 URL: https://issues.apache.org/jira/browse/TIKA-2919
>             Project: Tika
>          Issue Type: Bug
>          Components: handler, ocr
>    Affects Versions: 1.21
>            Reporter: Klemens Dickbauer
>            Priority: Major
> When parsing a pdf document the handler creates a structure (and fires appropriate SAX
exents) that each page is wrapped into two <div> elements. The outer one of these has
no parent element, so when the subsequent endElement method is called for "html", a NPE occurs
when currentElement.parent is referenced:
> {code:java}
> java class ToXMLContentHandler:
> public void endElement(String uri, String localName, String qName) throws SAXException
>     if (this.inStartElement) {
>         this.write(" />");
>         this.inStartElement = false;
>     } else {
>         this.write("</");
>         this.write(qName);
>         this.write('>');
>     }
>     this.namespaces.clear();
>     this.currentElement = this.currentElement.parent;
> }
> {code}

This message was sent by Atlassian JIRA

View raw message