#!/usr/bin/perl use strict; use warnings; use Carp::Clan; use CAM::PDF; use LWP::UserAgent; use Perl6::Say; use Data::Dump qw(dump); my $ua = LWP::UserAgent->new; my $res = $ua->get("http://www.nttdocomo.co.jp/binary/pdf/service/imode/make/content/spec/imode_spec.pdf"); if ($res->is_success) { my $pdf = CAM::PDF->new($res->content); if ($CAM::PDF::errstr) { croak($CAM::PDF::errstr); } for my $p (1 .. $pdf->numPages) { say dump($pdf->getPageText($p)); } }
を実行すると、
Carp::Clan::__ANON__(): Incorrect password(s). The document cannot be decrypted.
となる也。
http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html
をcryptlib付きで、-nオプションを付与してあげるとテキスト化はできるようになります。
これってグレーだったりしませんか?
不正アクセス禁止法にはひっかからないとは思うのですが…。
それにしても、xdoc2txtが空パスのPDFをdecryptできてCAM::PDFができないのはなんでなんだろう。
xdoc2txtがOpensorceじゃないのでいまいち追う気にはならない・・・。