PDF Hacks

PDF Hacks

Pdfgrep–freely search PDF with a grep like software

pdfgrep – search pdf files for a regular expression, it works similar to grep.

pdfgrep is an open source project developed by Hans-Peter Deifel, before RubyPDF blog released Pdfgrep Windows version, we can only find Linux and Mac version.

pdfgrep works much like grep, with one distinction: It operates on pages and not on lines.  


Ignore case distinctions in both the PATTERN and the input files.
Print the file name for each match. This is the default setting when there is more than one file to search.
Suppress the prefixing of file name on output. This is the default setting when there is only one file to search.
Prefix each match with the number of the page where it was found.
Suppress normal output. Instead print the number of matches for each input file. Note that unlike grep, multiple matches on the same page will be counted individually.
-C–context NUM
Print at most NUM characters of context around each match. The exact number will vary, because pdfgrep tries to respect word boundaries. If NUM is “line“, the whole line will be printed. If this option is not set, pdfgrep tries to print lines that are not longer than the terminal width.
–color WHEN
Surround file names, page numbers and matched text with escape sequences to display them in color on the terminal. (The default setting is auto).

WHEN can be:

Always use colors, even when stdout is not a terminal.
Do not use colors.
Use colors only when stdout is a terminal.
Recursively search all files (restricted by –include and –exclude) under each directory.
Skip files whose base name matches GLOB. See glob(7) for wildcards you can use. You can use this option multiple times to exclude more patterns. It takes precedence over –include. Note, that in- and excludes apply only to files found via –recursive and not to the argument list.
Only search files whose base name matches GLOB. See –exclude for details. The default is *.pdf.
Remove accents and ligatures from both the search pattern and the PDF documents. This is useful if you want to search for a word containing ‘ae’, but the PDF uses the single character ‘æ’ instead. See unac(3) and unaccent(1) for details.

[This option is experimental and only available if pdfgrep is compiled with unac support.]

Suppress all normal output to stdout. Errors will be printed and the exit codes will be returned (see below).
Print a short summary of the options.
Show version information







September 4, 2012 - Posted by | Uncategorized | , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: