tags:

views:

43

answers:

1

So, I have a .pdf file and I need to be able to determine if it was created by being scanned into a PDF or not. I'm trying to determine if it is a pdf I can display as text or not.

I have PHP & Zend at my disposal. I'm thinking I might be able to use Zend's

$pdf->properties['Producer']

but I'm not 100% sure.

Is there any way to be sure of what kind of .pdf file I'm dealing with?

+2  A: 

Sounds difficult to me. There are tons of different "Producer" IDs around, many of which support the generation of PDFs out of any kind of source, be it scanned, coming from a Fax, a word processor or whatnot. There are so many ways to create a PDF file, you'll never be able to trace back what came from where.

If you want to determine whether you can display it as text or not, why not try to extract some actual text from it? If it's scanned (or any other kind of embedded image) it should have none or very little textual content. But then, there's OCR programs that create a scanned PDF that has machine-readable text coming along, too. How do you want to deal with that?

What is your ultimate goal with this?

Pekka
We offer a "View as text" link option. I'm trying to hide that option when the pdf is all scanned image (thus nothing shows up when viewed as text) - YOur idea makes sense - I should be able to extract the contents into a variable and then search the variable for actual text somehow. I was hoping to be able to get something from the pdf properties somehow.
Jason