If a PDF requires a password (and it isn't the empty string) and you have the 
password, you need to send it in via the ParseContext:

ParseContext context = new ParseContext();
        context.set(PasswordProvider.class, new PasswordProvider() {
            public String getPassword(Metadata metadata) {
                return "thisIsThePassword";
            }
        });

-----Original Message-----
From: question.answer...@gmail.com [mailto:question.answer...@gmail.com] 
Sent: Wednesday, September 14, 2016 11:55 AM
To: user@tika.apache.org
Subject: Re: Apache Tikaで、保護されたPDFを取り込むと全文が文字化けしている

Do you, says the text of the protected PDF files can not be parsed by Tika?
I, if the specification of Tika, you give up the Perth.
(あなたは、保護されたPDFファイルのテキストをTikaでパースできないと言って
いますか?
私は、Tikaの仕様なら、パースを諦めます。)


Is the specification of Tika?


-- 
question.answer...@gmail.com <question.answer...@gmail.com>



> Relying on google translate...  I'm not sure how protection could lead to 
> garbled text; if the file is password protected, you shouldn't get any text.
> 
> 
> Try troubleshooting with pure PDFBox:
> 
> https://wiki.apache.org/tika/Troubleshooting%20Tika#PDF_Text_Problems
> 
> 
> -----Original Message-----
> From: question.answer...@gmail.com [mailto:question.answer...@gmail.com] 
> Sent: Wednesday, September 14, 2016 7:22 AM
> To: user@tika.apache.org
> Subject: Apache Tikaで、保護されたPDFを取り込むと全文が文字化けしている
> 
> 皆様、始めまして。
> 
> Tika初心者です。
> 
> いきなりですが、表記件についてご質問させてください。
> 
> Apache Tikaで、保護されたPDFを取り込むと全文が文字化けしているのですが、
> これは、仕様でしょうか?
> 設定などで回避して文字化けなしで取り込む方法はありますでしょうか?
>   ※保護されていないPDFは、文字化けなく、取り込めます。
> 
> 原因は何で、対応策(Tikaへの設定?など)は、ありますでしょうか?
> 
> 
> ソース:
> -----------------------------------------------------
> File document = new File("/usr/local/sample.pdf"); Parser parser = new 
> AutoDetectParser(); ContentHandler handler = new 
> BodyContentHandler(Integer.MAX_VALUE);
> Metadata metadata = new Metadata();
> parser.parse(new FileInputStream(document), handler, metadata
>                                                                          , 
> new ParseContext()); String plainText = handler.toString(); 
> System.out.println(plainText);
> -----------------------------------------------------
> 
> 
> 補足:
> ・保護されたPDFは、手動でテキストのコピーができない。
> 
> 
> Tika初心者


Reply via email to