Needing to search for a text string not just in the PDF file body, but also in the comments, I've installed Acrobat Reader on Ubuntu 18.04 LTS. Its search function works properly, but I'm wondering if there's another way to accomplish that task (pdfgrep?)
1. Strings in comments inside a PDF's source code
For strings in comments inside the PDF source code, you can safely assume that these are not encoded and appear as plain ASCII or UTF-8 text.
Hence the following command should work:
strings my.pdf | grep -i 'searchstring'
I should add that comments in PDF source code would be marked by a
%-character at the beginning of each comment line.
Also, neither Adobe Acrobat nor Adobe Reader will show up any results for strings in comments when you search for them.
2. Strings inside the text content of a PDF
You cannot assume to find text in a PDF so easily. You can do the following in order to find a certain string, though:
pdftotext -layout my.pdf - | grep -i 'searchstring'
There are quite a few other command line methods (you yourself mentioned
pdfgrep), though. Take
pdfgrep -n -i 'searchstring' my.pdf
-n prints the page number with a match for the string,
-i makes the search case-insensitive.)