2
$\begingroup$

I'm trying to import a PDF file whose text I'd like to parse, but I'm getting an error with no explanation:

Import["foobar.pdf", {"PDF", "Plaintext"}]
(* $Failed *)

I know the file exists as named, because if it didn't, $Mathematica$ would show a message:

Import["foobaz.pdf", {"PDF", "Plaintext"}]
(* Import::nffil: File not found during Import. *)
(* $Failed *)

Is there any way to get more information than the $Failed?

$\endgroup$

2 Answers 2

6
$\begingroup$

If the PDF file was composed with one of the latest security features of Adobe, you will not be able to parse. You need adobe Acrobat Pro to remove the security feature. This is assuming you have the priviledge to do so.

Another option is to print the file to Paperport PDF convert to PDF format and re export to PDF. But this might defeat your purpose to extract all the text from the orginal file.

$\endgroup$
1
  • $\begingroup$ That was exactly the problem. Thanks! $\endgroup$ Commented Apr 19, 2014 at 16:12
4
$\begingroup$

I'm posting a separate answer to show what I did but please upvote @JoseECalderon if you find this answer useful, as he led me in the right direction regarding security settings.

Unfortunately the security settings on my document prevented even printing to a (clean) PDF:

enter image description here

I found a blog post where someone needed to unlock exactly the documents I'm working with: downloadable American Express statements. This person ended up using MuPDF, which worked for me as well. After downloading and extracting the Windows executable from their Downloads page (and adding the executable to my Windows $PATH), I ran

mutools.exe clean foobar.pdf foobar-unlocked.pdf

and then was able to import the PDF.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.