Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm checking references of a paper and want to find the positions in the body where some paper (in the references list) is referenced. Is there a PDF editor which supports search via bash and extract the context of a position? I've tried to convert PDF to text, but didn't have a good result.

share|improve this question
up vote 17 down vote accepted

Just to add to the above answer, in particular you can use a command line tool from xpdf-utils called pdftotext and then search the text document created by this tool with grep.

This might look something like this:

pdftotext document.pdf - | grep -C5 -n -i "search term"

There is more information in the manual. The only drawback to pdftotext is that you can't us globbing to transform multiple files at the same time. This problem can be overcome with a small bash script:

for f in pdf_directory; do echo $f; pdftotext $f - | grep -i "search_term"; done

If you are having problems creating a text document from a pdf due to, for example, an incompatible pdf file, then that is another problem.

I think in general, pdf editors don't include command lines because they are graphical. If you want to use bash, (or maybe zsh!) then you might have to use a terminal shell.

Good luck!

share|improve this answer
grep is powerful,thanks! – David Sep 6 '12 at 8:32

You can use xpdf-utils. xpdf is a suite of tools for Portable Document Format (PDF) files.

To install it you can use the Ubuntu Software Center, or by clicking below:


Pdfgrep is a tool to search text in PDF files. It works similar to `grep'.


  • search for regular expressions.
  • support for some important grep options, including: + filename output. + page number output. + optional case insensitivity. + count
  • and the most important feature: color output!

1Source:Ubuntu Apps Directory

share|improve this answer

To search for a regular expression in multiple pdf files using pdfgrep:

find /path -iname '*.pdf' -exec pdfgrep -H 'pattern' {} \;

where path is location for your pdf files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.