2
$\begingroup$

I am trying to what I think should be a very basic thing, which is to import a large PDF from my files into Mathematica. The long term goal is to extract images from the PDF. The original command was

Import["Users/carlaj/Documents/Laurel/jotb.pdf"];

And that didn't work. It said that the filters were unknown (JBIG2Decode, and JPXDecode), and that:

LinkObject::linkd: "Unable to communicate with closed link \!\(LinkObject[\"'/Applications/Mathematica.app/Contents/SystemFiles/Converters/Binaries/MacOSX-x86-64/PDF.exe'\", 4465, 12]\). "

So I tested that it could, in fact, import from this file location and wrote:

Import["Users/carlaj/Documents/Laurel/jotbocr.txt"];

Which worked fine.

So, I tried importing a few other files, one from the same folder, "Laurel", one from the internet, and one from a different folder. None of these worked, but for different reasons. Basically it would appear that it won't import PDFs. See the image for various complications.

Failed PDF imports, plus detailed feedback

What do you think is going on? I'm pretty new to Mathematica, so it's totally possible I'm making a mistake, but I don't understand what's going on.

Here is a URL to one of the PDFs that isn't working: http://ia802702.us.archive.org/9/items/jockofthebushveld00fitziala/jockofthebushveld00fitziala.pdf

This is the online version, and the saved version is the one that I am working with.

$\endgroup$
  • 2
    $\begingroup$ Mathematica doesn't handle every PDF document. It usually helps to convert the PDF to an older version format, or to just re-process it through some tool you have available (Acrobat, OS X Preview, Ghostscript, mupdf, xpdf can all be useful). $\endgroup$ – Szabolcs Feb 27 '16 at 20:34
  • $\begingroup$ Please share at least some of the problematic PDFs in order to allow us to experiment with them. $\endgroup$ – Alexey Popkov Feb 27 '16 at 20:47
  • $\begingroup$ I added a link in the original post, hopefully that helps. I will try to reprocess it through OS X Preview or something and let you know how it goes. $\endgroup$ – Carla Joubert Feb 27 '16 at 22:40
  • $\begingroup$ Your PDF is a scanned and OCR'ed version of a printed book. Are you sure it is a good idea to import it into Mathematica? If you need to process scanned images, I would suggest to export them from the PDF as TIFF files (you can do this using Acrobat or free pdfimages utility from Poppler) and then process TIFF files in Mathematica. $\endgroup$ – Alexey Popkov Feb 28 '16 at 6:29
  • $\begingroup$ So, sort of for practicing purposes I wanted to extract the images from throughout the text, but I do also need the images. I will try exporting them as TIFF files, thanks. $\endgroup$ – Carla Joubert Feb 28 '16 at 6:44
1
$\begingroup$

Your PDF is a scanned and OCR'ed version of a printed book created by LuraTech PDF Compressor. If you need to process scanned images, I would suggest to export them from the PDF as TIFF files (you can do this using Acrobat or free pdfimages utility from Poppler) and then process TIFF files in Mathematica.

Note also that in your PDF the scanned color images are converted into stacks of layers each encoded either as JPEG2000 (which Mathematica can import) or as JBIG2 (unsupported by Mathematica). So the simplest solution is to use Acrobat which will automatically merge them into single TIFF files (pdfimages extracts layers as separate files).

$\endgroup$
  • $\begingroup$ Okay! I have imported it as a TIFF after converting it in OS X Preview. I also successfully imported a plain text version available on BHL. $\endgroup$ – Carla Joubert Feb 28 '16 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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