You have nothing to worry about. We will show you hot to easily convert PDF files to editable text using a command line tool called pdftotext, that is part of the “poppler-utils” package. This tool may already be installed on your PC. To check if it is installed on your system, press “Ctrl + Alt + T” to open a terminal window. Type the following command below and press “Enter”
dpkg –s poppler-utils
NOTE: When typing something and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.
If you’ve not installed pdftotext, type the following command below and press “Enter”.
sudo apt-get install poppler-utils
Type your password when it ask you to and press “Enter”.
There are so many tools available in the poppler-utils package for converting PDF to different formats, manipulating PDF files, and extracting information from files.
The following is the basic command for converting a PDF file to an editable text file. Press “Ctrl + Alt + T” to open a Terminal window, type the command below, and press “Enter”.
pdftotext /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt
Change the path to each file to correspond to the location and name of your original PDF file and where you want to save the resulting text file. Also, change the filenames to correspond to the names of your files.
The text file is created and can be opened just as you would open any other text file in Linux.
The converted PDF file may have line breaks where you don’t expect it to have them. Line breaks are inserted after every line of text in the PDF file.
You can preserve the layout of your document (headers, footers, paging, etc.) from the original PDF file in the converted text file using the “-layout” flag.
pdftotext -layout /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt
If you don’t want to convert all the pages in a PDF file, use the “-f” and “-l” (a lowercase “L”) flags to specify the first and last pages in the range you want to convert.
pdftotext -f 5 -l 9 /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt
This is how to convert a PDF file that’s protected and encrypted with a password, use the “-opw” flag (the first character in the flag is a lowercase letter “O”, not a zero).
pdftotext -opw ‘password’ /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt
Change “password” to the one used to protect the original PDF file being converted. Make sure there are single quotes, not double, around “password”.
If the PDF file is protected and encrypted with a user password, use the “-upw” flag instead of the “-opw” flag. The rest of the command is the same.
You can also specify the type of end-of-line character that is applied to the converted text. This is especially useful if you want to use the file on Windows or Mac. To do this, use the “-eol” flag (the middle character in the flag is a lowercase letter “O”, not a zero) then give it a space and the type of end-of-line character you want to use (“unix”, “dos”, or “mac”).
If you don’t specify a filename for the text file you want to convert, pdftotext automatically uses the base of the PDF filename and adds the “.txt” extension. For example, “file.pdf” will be converted to “file.txt”. If the text file is specified as “-“, the converted text is sent to stdout, which means the text is displayed in the Terminal window and not saved to a file.
To close the Terminal window, click the “X” button in the upper-left corner.