Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
That was exactly the problem. Thanks! –  Andrew Cheong Apr 19 at 16:12
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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