You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tika.apache.org by Mark Kerzner <ma...@gmail.com> on 2009/03/30 18:20:11 UTC

Testing Tika

Hi,
I am testing Tika on a set of about 200 documents, and I am planning more
extensive tests. At the moment, it crashes on one PDF and on quite a few
hmlt files.

Of course I realize that these questions should be addressed to individual
converter maintainers, that is, PDFBox and Neko html parser. But I am
looking for a central point to work on this, if there is one.

I have seen that this problem with Neka parser has been identified as a bug
in JIRA a few days ago. I would love to fix it, since I am falling back on
another html parser, http://htmlparser.sourceforge.net/, and this causes me
other problems. For example, being that I am testing for results after
the conversation is done and I invoke the http://htmlparser.sourceforge.net/ on
empty results. now I am converting mp3 as html :(

So, I would rather improve the Tika framework than find hacks. I am doing
this as part of a commercial project, so I don't mind fixing stuff and
contributing back.

Any pointers will be appreciated.

Thank you,
Mark

Re: Testing Tika

Posted by Peter Becker <pe...@peterbecker.de>.
Jukka Zitting wrote:

[...]
>> Neko gives a null pointer exception, and I see this bug submitted in Jira a
>> few days ago.
>>     
>
> OK. I think Tika should be better prepared to handle even NPEs and
> other RuntimeExceptions from parser libraries.
>   
In our code we went even further and caught Throwable. Sounds nasty at 
first, but you really want to catch at least those OutOfMemoryErrors 
some parsers can throw -- in the context of extracting text from a file 
they are usually recoverable. We (the Docco project) have encountered 
that problem in various cases. We decided that we want to try to recover 
from anything that happens during parsing of a single document and map 
that into one of our exceptions to report that the document couldn't be 
parsed -- but continue otherwise.

The one thing that still got us was Multivalent doing a System.exit(..) 
on parse errors, but I believe they fixed that years ago :-) It's odd 
when your GUI program disappears without any message and you have no 
clue why.

  Peter

Re: Testing Tika

Posted by Aaron Fulton <aa...@softhome.net>.
I've come across this error too.  I know that in adobe acrobat pro you 
can set passwords for viewing and passwords for editing.  My guess is 
that the offending pdf has an edit password set.  I know that some 
packages (eg pdf2text - part of the xpdf project) can ignore this and 
extract the text regardless.

Jukka Zitting wrote:
> Hi,
>
> On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com> wrote:
>   
>> For the attached PDF file I get this exception
>> org.apache.tika.exception.TikaException: Unable to extract PDF content
>>     
>
> The underlying PDFBox exception seems to be:
>
> Error: The supplied password does not match either the owner or user
> password in the document.
> 	at org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
> 	at org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
>
> I'm able to open the document normally using Acrobat Reader, so I
> guess PDFBox is simply getting confused about the document.
>
>   
>> Neko gives a null pointer exception, and I see this bug submitted in Jira a
>> few days ago.
>>     
>
> OK. I think Tika should be better prepared to handle even NPEs and
> other RuntimeExceptions from parser libraries.
>
> BR,
>
> Jukka Zitting
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.285 / Virus Database: 270.11.32/2030 - Release Date: 03/30/09 08:40:00
>
>   


Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
Uwe,

do you still want me to create a JIRA issue for this?

Thank you,
Mark

On Fri, Apr 3, 2009 at 11:24 AM, Mark Kerzner <ma...@gmail.com> wrote:

> Uwe,
> here is the Shakespeare's Midsummer Night's Dream, obviously in the public
> domain, and converted to a PDF that gives you the same problem on
> extraction.
>
> I hope that's good enough, if not - please tell me.
>
> Thank you,
> Mark
>
>
> On Thu, Apr 2, 2009 at 6:32 PM, Mark Kerzner <ma...@gmail.com>wrote:
>
>> I will try to generate one tomorrow. I have a complete PDF program, and I
>> think the whole problem is that it should be "Restricted"
>>
>> Mark <http://shmsoft.com/aboutmark.html>
>>
>>
>> On Thu, Apr 2, 2009 at 5:32 PM, Jukka Zitting <ju...@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> On Thu, Apr 2, 2009 at 11:48 PM, Mark Kerzner <ma...@gmail.com>
>>> wrote:
>>> > Uwe, you can use this PDF, because I found it on the web, so it's
>>> public.
>>>
>>> Unfortunately that's not enough for us.
>>>
>>> The document being public makes it OK for you or I to download and
>>> view it (and try PDFBox on it), but that's not enough for Tika as an
>>> open source project to include and redistribute the document. We need
>>> an ALv2-compatible license for everything we include in Tika.
>>>
>>> It would be ideal if someone could generate a simplified PDF document
>>> that illustrates the same problem. Alternatively the best we can do is
>>> just to attach the current example document in the Jira issue (with
>>> the "Attachment not intended for inclusion" option selected) so
>>> everyone who is looking at the change can at least manually download
>>> the document and try it for themselves.
>>>
>>> BR,
>>>
>>> Jukka Zitting
>>>
>>
>>
>

Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
Uwe,
here is the Shakespeare's Midsummer Night's Dream, obviously in the public
domain, and converted to a PDF that gives you the same problem on
extraction.

I hope that's good enough, if not - please tell me.

Thank you,
Mark

On Thu, Apr 2, 2009 at 6:32 PM, Mark Kerzner <ma...@gmail.com> wrote:

> I will try to generate one tomorrow. I have a complete PDF program, and I
> think the whole problem is that it should be "Restricted"
>
> Mark <http://shmsoft.com/aboutmark.html>
>
>
> On Thu, Apr 2, 2009 at 5:32 PM, Jukka Zitting <ju...@gmail.com>wrote:
>
>> Hi,
>>
>> On Thu, Apr 2, 2009 at 11:48 PM, Mark Kerzner <ma...@gmail.com>
>> wrote:
>> > Uwe, you can use this PDF, because I found it on the web, so it's
>> public.
>>
>> Unfortunately that's not enough for us.
>>
>> The document being public makes it OK for you or I to download and
>> view it (and try PDFBox on it), but that's not enough for Tika as an
>> open source project to include and redistribute the document. We need
>> an ALv2-compatible license for everything we include in Tika.
>>
>> It would be ideal if someone could generate a simplified PDF document
>> that illustrates the same problem. Alternatively the best we can do is
>> just to attach the current example document in the Jira issue (with
>> the "Attachment not intended for inclusion" option selected) so
>> everyone who is looking at the change can at least manually download
>> the document and try it for themselves.
>>
>> BR,
>>
>> Jukka Zitting
>>
>
>

Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
I will try to generate one tomorrow. I have a complete PDF program, and I
think the whole problem is that it should be "Restricted"

Mark <http://shmsoft.com/aboutmark.html>

On Thu, Apr 2, 2009 at 5:32 PM, Jukka Zitting <ju...@gmail.com>wrote:

> Hi,
>
> On Thu, Apr 2, 2009 at 11:48 PM, Mark Kerzner <ma...@gmail.com>
> wrote:
> > Uwe, you can use this PDF, because I found it on the web, so it's public.
>
> Unfortunately that's not enough for us.
>
> The document being public makes it OK for you or I to download and
> view it (and try PDFBox on it), but that's not enough for Tika as an
> open source project to include and redistribute the document. We need
> an ALv2-compatible license for everything we include in Tika.
>
> It would be ideal if someone could generate a simplified PDF document
> that illustrates the same problem. Alternatively the best we can do is
> just to attach the current example document in the Jira issue (with
> the "Attachment not intended for inclusion" option selected) so
> everyone who is looking at the change can at least manually download
> the document and try it for themselves.
>
> BR,
>
> Jukka Zitting
>

Re: Testing Tika

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Apr 2, 2009 at 11:48 PM, Mark Kerzner <ma...@gmail.com> wrote:
> Uwe, you can use this PDF, because I found it on the web, so it's public.

Unfortunately that's not enough for us.

The document being public makes it OK for you or I to download and
view it (and try PDFBox on it), but that's not enough for Tika as an
open source project to include and redistribute the document. We need
an ALv2-compatible license for everything we include in Tika.

It would be ideal if someone could generate a simplified PDF document
that illustrates the same problem. Alternatively the best we can do is
just to attach the current example document in the Jira issue (with
the "Attachment not intended for inclusion" option selected) so
everyone who is looking at the change can at least manually download
the document and try it for themselves.

BR,

Jukka Zitting

Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
Uwe, you can use this PDF, because I found it on the web, so it's public.
I will create a JIRA issue - but tomorrow, since I am running away (to a
concert :), so if you can wait - fine, if not - you can create your won.

Thank you,
Mark

On Thu, Apr 2, 2009 at 4:42 PM, Uwe Schindler <uw...@thetaphi.de> wrote:

>  Hi Mark,
>
>
>
> with the attached patch, TIKA can decode encrypted PDFs (I tested it with
> your example). I think this patch should be applied to TIKA and all other
> projects using this empty password hack with newer PDFBox versions. Can you
> create an JIRA issue and I attach the patch after? I would like to add a
> test case to it, too. Can we use your example PDF for the test case?
>
>
>
> Uwe
>
>
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>   ------------------------------
>
> *From:* Mark Kerzner [mailto:markkerzner@gmail.com]
> *Sent:* Thursday, April 02, 2009 9:31 PM
>
> *To:* tika-user@lucene.apache.org
> *Subject:* Re: Testing Tika
>
>
>
> If I want to process such protected PDF's, should I hack Tika somehow, or
> should I wait for a change? Should I fix it and commit the change?
>
>
>
> Thank you,
>
> Mark
>
> On Tue, Mar 31, 2009 at 1:20 AM, Uwe Schindler <uw...@thetaphi.de> wrote:
>
> Hi Jukka,
>
> the problem is mostly the following (I wrote a PDF text extractor in the
> past, too): The current code in TIKA checks after opening the document, if
> a
> PDF document is encrypted, and if so, it tries to set an empty string as
> password. With newer versions of PDFBox, it seems that this is no longer
> needed. It can read encrypted documents that have a password for writing
> without any further checks. Just try to remove this "set empty password"
> part from TIKA and it will work.
>
> I am not really sure, why this bad "hack" is always used together with
> PDFBOX (nutch does this, a lot of examples from the web, too). I was able
> to
> extract text from thousand of PDFs with just this short code snippet:
>
>                Writer out=...
>                PDDocument pd=PDDocument.load(in);
>                try {
>                        PDFTextStripper stripper = new PDFTextStripper();
>                        stripper.writeText(pd,out);
>                } finally {
>                        try {
>                                pd.close();
>                        } catch (IOException e) {}
>                }
>
> So it des not detect encryption or anything else and it was able to extract
> text from encrypted douments. Only documents that have a real password set
> for reading were failing (but this is intended).
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> > Sent: Tuesday, March 31, 2009 2:18 AM
> > To: tika-user@lucene.apache.org
> > Subject: Re: Testing Tika
> >
> > Hi,
> >
> > On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com>
> > wrote:
> > > For the attached PDF file I get this exception
> > > org.apache.tika.exception.TikaException: Unable to extract PDF content
> >
> > The underlying PDFBox exception seems to be:
> >
> > Error: The supplied password does not match either the owner or user
> > password in the document.
> >       at
> > org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
> >       at
> org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
> >
> > I'm able to open the document normally using Acrobat Reader, so I
> > guess PDFBox is simply getting confused about the document.
> >
> > > Neko gives a null pointer exception, and I see this bug submitted in
> > Jira a
> > > few days ago.
> >
> > OK. I think Tika should be better prepared to handle even NPEs and
> > other RuntimeExceptions from parser libraries.
> >
> > BR,
> >
> > Jukka Zitting
>
>
>

Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
Uwe, can you tell me what is the status on this?

On Thu, Apr 2, 2009 at 4:42 PM, Uwe Schindler <uw...@thetaphi.de> wrote:

>  Hi Mark,
>
>
>
> with the attached patch, TIKA can decode encrypted PDFs (I tested it with
> your example). I think this patch should be applied to TIKA and all other
> projects using this empty password hack with newer PDFBox versions. Can you
> create an JIRA issue and I attach the patch after? I would like to add a
> test case to it, too. Can we use your example PDF for the test case?
>
>
>
> Uwe
>
>
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>   ------------------------------
>
> *From:* Mark Kerzner [mailto:markkerzner@gmail.com]
> *Sent:* Thursday, April 02, 2009 9:31 PM
>
> *To:* tika-user@lucene.apache.org
> *Subject:* Re: Testing Tika
>
>
>
> If I want to process such protected PDF's, should I hack Tika somehow, or
> should I wait for a change? Should I fix it and commit the change?
>
>
>
> Thank you,
>
> Mark
>
> On Tue, Mar 31, 2009 at 1:20 AM, Uwe Schindler <uw...@thetaphi.de> wrote:
>
> Hi Jukka,
>
> the problem is mostly the following (I wrote a PDF text extractor in the
> past, too): The current code in TIKA checks after opening the document, if
> a
> PDF document is encrypted, and if so, it tries to set an empty string as
> password. With newer versions of PDFBox, it seems that this is no longer
> needed. It can read encrypted documents that have a password for writing
> without any further checks. Just try to remove this "set empty password"
> part from TIKA and it will work.
>
> I am not really sure, why this bad "hack" is always used together with
> PDFBOX (nutch does this, a lot of examples from the web, too). I was able
> to
> extract text from thousand of PDFs with just this short code snippet:
>
>                Writer out=...
>                PDDocument pd=PDDocument.load(in);
>                try {
>                        PDFTextStripper stripper = new PDFTextStripper();
>                        stripper.writeText(pd,out);
>                } finally {
>                        try {
>                                pd.close();
>                        } catch (IOException e) {}
>                }
>
> So it des not detect encryption or anything else and it was able to extract
> text from encrypted douments. Only documents that have a real password set
> for reading were failing (but this is intended).
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> > Sent: Tuesday, March 31, 2009 2:18 AM
> > To: tika-user@lucene.apache.org
> > Subject: Re: Testing Tika
> >
> > Hi,
> >
> > On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com>
> > wrote:
> > > For the attached PDF file I get this exception
> > > org.apache.tika.exception.TikaException: Unable to extract PDF content
> >
> > The underlying PDFBox exception seems to be:
> >
> > Error: The supplied password does not match either the owner or user
> > password in the document.
> >       at
> > org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
> >       at
> org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
> >
> > I'm able to open the document normally using Acrobat Reader, so I
> > guess PDFBox is simply getting confused about the document.
> >
> > > Neko gives a null pointer exception, and I see this bug submitted in
> > Jira a
> > > few days ago.
> >
> > OK. I think Tika should be better prepared to handle even NPEs and
> > other RuntimeExceptions from parser libraries.
> >
> > BR,
> >
> > Jukka Zitting
>
>
>

RE: Testing Tika

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi Mark,

 

with the attached patch, TIKA can decode encrypted PDFs (I tested it with
your example). I think this patch should be applied to TIKA and all other
projects using this empty password hack with newer PDFBox versions. Can you
create an JIRA issue and I attach the patch after? I would like to add a
test case to it, too. Can we use your example PDF for the test case?

 

Uwe

 

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

  _____  

From: Mark Kerzner [mailto:markkerzner@gmail.com] 
Sent: Thursday, April 02, 2009 9:31 PM
To: tika-user@lucene.apache.org
Subject: Re: Testing Tika

 

If I want to process such protected PDF's, should I hack Tika somehow, or
should I wait for a change? Should I fix it and commit the change?

 

Thank you,

Mark

On Tue, Mar 31, 2009 at 1:20 AM, Uwe Schindler <uw...@thetaphi.de> wrote:

Hi Jukka,

the problem is mostly the following (I wrote a PDF text extractor in the
past, too): The current code in TIKA checks after opening the document, if a
PDF document is encrypted, and if so, it tries to set an empty string as
password. With newer versions of PDFBox, it seems that this is no longer
needed. It can read encrypted documents that have a password for writing
without any further checks. Just try to remove this "set empty password"
part from TIKA and it will work.

I am not really sure, why this bad "hack" is always used together with
PDFBOX (nutch does this, a lot of examples from the web, too). I was able to
extract text from thousand of PDFs with just this short code snippet:

               Writer out=...
               PDDocument pd=PDDocument.load(in);
               try {
                       PDFTextStripper stripper = new PDFTextStripper();
                       stripper.writeText(pd,out);
               } finally {
                       try {
                               pd.close();
                       } catch (IOException e) {}
               }

So it des not detect encryption or anything else and it was able to extract
text from encrypted douments. Only documents that have a real password set
for reading were failing (but this is intended).

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> Sent: Tuesday, March 31, 2009 2:18 AM
> To: tika-user@lucene.apache.org
> Subject: Re: Testing Tika
>
> Hi,
>
> On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com>
> wrote:
> > For the attached PDF file I get this exception
> > org.apache.tika.exception.TikaException: Unable to extract PDF content
>
> The underlying PDFBox exception seems to be:
>
> Error: The supplied password does not match either the owner or user
> password in the document.
>       at
> org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
>       at org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
>
> I'm able to open the document normally using Acrobat Reader, so I
> guess PDFBox is simply getting confused about the document.
>
> > Neko gives a null pointer exception, and I see this bug submitted in
> Jira a
> > few days ago.
>
> OK. I think Tika should be better prepared to handle even NPEs and
> other RuntimeExceptions from parser libraries.
>
> BR,
>
> Jukka Zitting

 


Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
If I want to process such protected PDF's, should I hack Tika somehow, or
should I wait for a change? Should I fix it and commit the change?
Thank you,
Mark

On Tue, Mar 31, 2009 at 1:20 AM, Uwe Schindler <uw...@thetaphi.de> wrote:

> Hi Jukka,
>
> the problem is mostly the following (I wrote a PDF text extractor in the
> past, too): The current code in TIKA checks after opening the document, if
> a
> PDF document is encrypted, and if so, it tries to set an empty string as
> password. With newer versions of PDFBox, it seems that this is no longer
> needed. It can read encrypted documents that have a password for writing
> without any further checks. Just try to remove this "set empty password"
> part from TIKA and it will work.
>
> I am not really sure, why this bad "hack" is always used together with
> PDFBOX (nutch does this, a lot of examples from the web, too). I was able
> to
> extract text from thousand of PDFs with just this short code snippet:
>
>                Writer out=...
>                PDDocument pd=PDDocument.load(in);
>                try {
>                        PDFTextStripper stripper = new PDFTextStripper();
>                        stripper.writeText(pd,out);
>                } finally {
>                        try {
>                                pd.close();
>                        } catch (IOException e) {}
>                }
>
> So it des not detect encryption or anything else and it was able to extract
> text from encrypted douments. Only documents that have a real password set
> for reading were failing (but this is intended).
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> > Sent: Tuesday, March 31, 2009 2:18 AM
> > To: tika-user@lucene.apache.org
> > Subject: Re: Testing Tika
> >
> > Hi,
> >
> > On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com>
> > wrote:
> > > For the attached PDF file I get this exception
> > > org.apache.tika.exception.TikaException: Unable to extract PDF content
> >
> > The underlying PDFBox exception seems to be:
> >
> > Error: The supplied password does not match either the owner or user
> > password in the document.
> >       at
> > org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
> >       at
> org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
> >
> > I'm able to open the document normally using Acrobat Reader, so I
> > guess PDFBox is simply getting confused about the document.
> >
> > > Neko gives a null pointer exception, and I see this bug submitted in
> > Jira a
> > > few days ago.
> >
> > OK. I think Tika should be better prepared to handle even NPEs and
> > other RuntimeExceptions from parser libraries.
> >
> > BR,
> >
> > Jukka Zitting
>
>

Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
Hi all,

another error I get with PDFBox is this

java.lang.NullPointerException
        at
org.pdfbox.pdmodel.common.COSStreamArray.getUnfilteredStream(COSStreamArray.java:200)
        at
org.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:101)
        at
org.pdfbox.pdmodel.common.COSStreamArray.getStreamTokens(COSStreamArray.java:141)
        at
org.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:202)
        at
org.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:174)
        at
org.pdfbox.util.PDFTextStripper.processPage(PDFTextStripper.java:336)
        at
org.pdfbox.util.PDFTextStripper.processPages(PDFTextStripper.java:259)
        at
org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:216)
        at org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
        at org.apache.tika.parser.pdf.PDF2XHTML.process(PDF2XHTML.java:53)
        at org.apache.tika.parser.pdf.PDFParser.parse(PDFParser.java:51)
        at
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:108)
        at
org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:78)

And the file that makes this happen is attached. In this case, the file was
created by my daughter as homework, so creative commons license is no
problem.

Thank you,
Mark

On Tue, Mar 31, 2009 at 1:20 AM, Uwe Schindler <uw...@thetaphi.de> wrote:

> Hi Jukka,
>
> the problem is mostly the following (I wrote a PDF text extractor in the
> past, too): The current code in TIKA checks after opening the document, if
> a
> PDF document is encrypted, and if so, it tries to set an empty string as
> password. With newer versions of PDFBox, it seems that this is no longer
> needed. It can read encrypted documents that have a password for writing
> without any further checks. Just try to remove this "set empty password"
> part from TIKA and it will work.
>
> I am not really sure, why this bad "hack" is always used together with
> PDFBOX (nutch does this, a lot of examples from the web, too). I was able
> to
> extract text from thousand of PDFs with just this short code snippet:
>
>                Writer out=...
>                PDDocument pd=PDDocument.load(in);
>                try {
>                        PDFTextStripper stripper = new PDFTextStripper();
>                        stripper.writeText(pd,out);
>                } finally {
>                        try {
>                                pd.close();
>                        } catch (IOException e) {}
>                }
>
> So it des not detect encryption or anything else and it was able to extract
> text from encrypted douments. Only documents that have a real password set
> for reading were failing (but this is intended).
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> > Sent: Tuesday, March 31, 2009 2:18 AM
> > To: tika-user@lucene.apache.org
> > Subject: Re: Testing Tika
> >
> > Hi,
> >
> > On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com>
> > wrote:
> > > For the attached PDF file I get this exception
> > > org.apache.tika.exception.TikaException: Unable to extract PDF content
> >
> > The underlying PDFBox exception seems to be:
> >
> > Error: The supplied password does not match either the owner or user
> > password in the document.
> >       at
> > org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
> >       at
> org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
> >
> > I'm able to open the document normally using Acrobat Reader, so I
> > guess PDFBox is simply getting confused about the document.
> >
> > > Neko gives a null pointer exception, and I see this bug submitted in
> > Jira a
> > > few days ago.
> >
> > OK. I think Tika should be better prepared to handle even NPEs and
> > other RuntimeExceptions from parser libraries.
> >
> > BR,
> >
> > Jukka Zitting
>
>

RE: Testing Tika

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi Jukka,

the problem is mostly the following (I wrote a PDF text extractor in the
past, too): The current code in TIKA checks after opening the document, if a
PDF document is encrypted, and if so, it tries to set an empty string as
password. With newer versions of PDFBox, it seems that this is no longer
needed. It can read encrypted documents that have a password for writing
without any further checks. Just try to remove this "set empty password"
part from TIKA and it will work.

I am not really sure, why this bad "hack" is always used together with
PDFBOX (nutch does this, a lot of examples from the web, too). I was able to
extract text from thousand of PDFs with just this short code snippet:

		Writer out=...
		PDDocument pd=PDDocument.load(in);
		try {
			PDFTextStripper stripper = new PDFTextStripper();
			stripper.writeText(pd,out);
		} finally {
			try {
				pd.close();
			} catch (IOException e) {}
		}

So it des not detect encryption or anything else and it was able to extract
text from encrypted douments. Only documents that have a real password set
for reading were failing (but this is intended).

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Jukka Zitting [mailto:jukka.zitting@gmail.com]
> Sent: Tuesday, March 31, 2009 2:18 AM
> To: tika-user@lucene.apache.org
> Subject: Re: Testing Tika
> 
> Hi,
> 
> On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com>
> wrote:
> > For the attached PDF file I get this exception
> > org.apache.tika.exception.TikaException: Unable to extract PDF content
> 
> The underlying PDFBox exception seems to be:
> 
> Error: The supplied password does not match either the owner or user
> password in the document.
> 	at
> org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
> 	at org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)
> 
> I'm able to open the document normally using Acrobat Reader, so I
> guess PDFBox is simply getting confused about the document.
> 
> > Neko gives a null pointer exception, and I see this bug submitted in
> Jira a
> > few days ago.
> 
> OK. I think Tika should be better prepared to handle even NPEs and
> other RuntimeExceptions from parser libraries.
> 
> BR,
> 
> Jukka Zitting


Re: Testing Tika

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Mar 30, 2009 at 7:20 PM, Mark Kerzner <ma...@gmail.com> wrote:
> For the attached PDF file I get this exception
> org.apache.tika.exception.TikaException: Unable to extract PDF content

The underlying PDFBox exception seems to be:

Error: The supplied password does not match either the owner or user
password in the document.
	at org.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:208)
	at org.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:149)

I'm able to open the document normally using Acrobat Reader, so I
guess PDFBox is simply getting confused about the document.

> Neko gives a null pointer exception, and I see this bug submitted in Jira a
> few days ago.

OK. I think Tika should be better prepared to handle even NPEs and
other RuntimeExceptions from parser libraries.

BR,

Jukka Zitting

Re: Testing Tika

Posted by Mark Kerzner <ma...@gmail.com>.
For the attached PDF file I get this exception
org.apache.tika.exception.TikaException: Unable to extract PDF content
        at org.apache.tika.parser.pdf.PDF2XHTML.process(PDF2XHTML.java:58)
        at org.apache.tika.parser.pdf.PDFParser.parse(PDFParser.java:51)
        at
org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:108)
        at
org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:80)

Neko gives a null pointer exception, and I see this bug submitted in Jira a
few days ago.

I will use Tika 0.3 to test text file recognition.

Thank you,
Mark

On Mon, Mar 30, 2009 at 12:12 PM, Jukka Zitting <ju...@gmail.com>wrote:

> Hi,
>
> On Mon, Mar 30, 2009 at 6:20 PM, Mark Kerzner <ma...@gmail.com>
> wrote:
> > I am testing Tika on a set of about 200 documents, and I am planning more
> > extensive tests. At the moment, it crashes on one PDF and on quite a few
> > hmlt files.
>
> Does "crashes" mean a) "process terminates with a core dump", b) "a
> RuntimeException (or an Error) is thrown" or c) "a TikaException is
> thrown".
>
> > Of course I realize that these questions should be addressed to
> individual
> > converter maintainers, that is, PDFBox and Neko html parser.
>
> For cases a) and b) we clearly should do something in Tika, but case
> c) is pretty much in the realm of the parser library we use. If a
> parser library doesn't work, we can either try to submit a patch there
> and upgrade to a more recent release, or replace the library with an
> alternative that works better. Adding Tika-specific customizations or
> workarounds isn't a viable strategy in the long run.
>
> BR,
>
> Jukka Zitting
>

Re: Testing Tika

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Mar 30, 2009 at 6:20 PM, Mark Kerzner <ma...@gmail.com> wrote:
> I am testing Tika on a set of about 200 documents, and I am planning more
> extensive tests. At the moment, it crashes on one PDF and on quite a few
> hmlt files.

Does "crashes" mean a) "process terminates with a core dump", b) "a
RuntimeException (or an Error) is thrown" or c) "a TikaException is
thrown".

> Of course I realize that these questions should be addressed to individual
> converterĀ maintainers, that is, PDFBox and Neko html parser.

For cases a) and b) we clearly should do something in Tika, but case
c) is pretty much in the realm of the parser library we use. If a
parser library doesn't work, we can either try to submit a patch there
and upgrade to a more recent release, or replace the library with an
alternative that works better. Adding Tika-specific customizations or
workarounds isn't a viable strategy in the long run.

BR,

Jukka Zitting