Searching for punctuation in Preview

internationalizationpdfpreviewsearch

In Preview (v 5.3 on 10.6.8), if I search for a single letter such as k in a pdf, the program will find and highlight every instance of that letter in the pdf.

However, if I search for a punctuation mark such as ? or ;, it will report Found on 0 pages, even when the document is littered with such punctuation.

How can I get preview to search for punctuation?

The reason for this is that I wish to locate all instances of missing references (denoted as [?]) in a pdf output from LaTeX.
(Yes, I know that LaTeX will tell me where they are in the source file, but I wish to find them in the pdf.)

Best Answer

Does it have to be in Preview? Preview doesn't seem to have this functionality as of El Capitan (10.11). However, I have found and tested two ways that you can search PDF files for punctuation.

  1. Acrobat Reader
  2. pdfgrep

Acrobat Reader

Using Adobe Acrobat, I simply entered the punctuation into the search field in this case a colon (:) and Acrobat found all instances of it.

Sample PDF Page

Note: I did successfully test out the question mark (?) and it worked. Unfortunately, the only document I had at the ready had personal info on it so I couldn't use it as an example. However, I made sure to test different punctuation from periods, exclamation points, question marks, commas, etc. and all worked.

pdfgrep

pdfgrep is the PDF equivalent to the command line (CLI) utility grep. The useage is simple:

pdfgrep [OPTIONS] PATTERN FILE

So, to search for a comma, and have it tell you what page number it occurs on, simply issue the command:

pdfgrep -n "?" foobar.pdf

pdfgrep is FOSS software and available on Homebrew and MacPorts. See man pdfgrep for more info.