pdftotext is a command-line tool that lets you extract text from PDF files in Termux. It converts PDF documents into plain text files. You can also extract text from specific pages, maintain the original layout, and choose different output formats.
Here’s what you can do with pdftotext in Termux:
- Convert PDF files into text files.
- Extract text from specific pages.
- Convert multiple pages at once.
- Maintain the original document layout.
- Choose different text encodings.
- Extract text without page breaks.
- Display URLs found inside PDF files.
- Generate HTML and TSV output.
- Work with password-protected PDF files.
Install pdftotext in Termux
Below is the simple command to install pdftotext in Termux, just copy and run the command in Termux.
First, update and upgrade the packages:
pkg update && pkg upgrade -yInstall Poppler:
pkg install poppler -ypdftotext is now ready to use in Termux.
Use pdftotext in Termux
Use the following commands to convert PDF files into text and explore different pdftotext options.
Convert a PDF file to a text file:
pdftotext file.pdfConvert a PDF file and choose an output file name:
pdftotext file.pdf output.txtExtract text from a specific page:
pdftotext -f 2 -l 2 file.pdf output.txtExtract text from pages 1 to 5:
pdftotext -f 1 -l 5 file.pdf output.txtMaintain the original document layout:
pdftotext -layout file.pdf output.txtExtract text in the original content stream order:
pdftotext -raw file.pdf output.txtConvert a PDF without inserting page breaks:
pdftotext -nopgbrk file.pdf output.txtExtract text and include URLs:
pdftotext -urls file.pdf output.txtGenerate HTML output with PDF metadata:
pdftotext -htmlmeta file.pdf output.htmlGenerate TSV output with text position information:
pdftotext -tsv file.pdf output.tsvChoose the output text encoding:
pdftotext -enc UTF-8 file.pdf output.txtList available text encodings:
pdftotext -listencDisplay the bounding box of each word:
pdftotext -bbox file.pdf output.htmlDisplay the bounding box with additional layout information:
pdftotext -bbox-layout file.pdf output.htmlConvert a password-protected PDF:
pdftotext -upw YOUR_PASSWORD file.pdf output.txtShow version information:
pdftotext -vShow the help menu:
pdftotext -hThese options give you more control over PDF conversion, page selection, and text output.
End Note
pdftotext is a useful command-line tool for extracting text from PDF documents in Termux. Its different options give you more control over page selection, text layout, encoding, and output formats.

