I get a File via a HTTP-Upload and need to be sure its a pdf-file. Programing Language is Python, but this should not matter.
I thought of the follow
The two most commonly used PDF libraries for Python are:
Both are pure python so should be easy to install as well be cross-platform.
With pyPdf it would probably be as simple as doing:
from pyPdf import PdfFileReader
doc = PdfFileReader(file("upload.pdf", "rb"))
This should be enough, but doc will now have documentInfo() and numPages() methods if you want to do further checking.
As Carl answered, pdftotext is also a good solution, and would probably be faster on very large documents (especially ones with many cross-references). However it might be a little slower on small PDF's due to system overhead of forking a new process, etc.