问题
I have a CSV with a list of URLs with PDFs:
- Some of these PDFs are searchable.
- Some of these PDFS aren't searchable.
I want to determine which PDFs are searchable from my list of PDFs. Is there an easy way to do this?
回答1:
On the commandline, I'd use pdffonts
to determine which fonts the file uses. This runs rather fast as well...
Example 1: PDF containing text
pdffonts bash-manpage.pdf name type encoding emb sub uni object ID ------------------------------- ------------- --------------- --- --- --- --------- Times-Roman Type 1 Custom no no no 8 0 Times-Bold Type 1 Standard no no no 9 0 Helvetica Type 1 Custom no no no 11 0 Helvetica-Bold Type 1 Standard no no no 30 0
Example 2: PDF containing only images
pdffonts scanned-book.pdf pdffonts handmade.pdf name type encoding emb sub uni object ID ------------------------------- -------------- -------------- --- --- --- ---------
Example 1 shows a table with font names. This means there IS text to search.
Example 2 shows an empty table. No fonts, no text to be searched (unless you run OCR on the file to first embed any found text... but then you've created a different file!), don't look back at these...
Note: to be successful in actually extracting the embedded text and hence being able to search it is an entirely different problem. There are many cases where you'll find it to be extremely difficult -- especially if you see in the fonts' table font types like CID Type
with 'custom' encoding. You may first want to search stackoverflow for other questions that were asked about text extraction from PDF...
来源:https://stackoverflow.com/questions/11820241/how-do-i-determine-programmatically-if-a-pdf-is-searchable