2

could anybody suggest me any simple linux command to open pdf files(text only) on command line. If we are able to pass the password as an argument to the command that would be more appreciated.

I am trying to build a script that iterates all the possible 4 character passwords, to crack password of a password protected pdf file.

Thanks in Advance Harsha

2
  • What password? An encrypted pdf?
    – jordanm
    Oct 15, 2013 at 22:20
  • yes, I am trying to build a script that iterates all the possible 4 character passwords, to crack password of a password protected pdf file.
    – Harsha
    Oct 15, 2013 at 22:32

3 Answers 3

2

To read PDFs on the terminal you could use a framebuffer PDF viewer like fbgs (based on the fbi image viewer and gs). From the home page:

fbgs: A wrapper script for viewing ps/pdf files on the framebuffer console using fbi.

If X applications are allowed just call the users default PDF viewer using

xdg-open file.pdf

If you want do do further PDF manipulations hava a look at pdftk, it allows to set the password and many more features.

1

pdftotext is part of the xpdf package. It'll output to a text file. If no output file is specified, you'll end up with a file of the same name, but a '.txt' extension.

pdftotext -layout file.pdf [output.txt]

You can pass passwords to it.

man pdftotext |grep -i password
  -opw password
  Specify the owner password for the PDF file.  Providing this will bypass all security restrictions.
  -upw password
  Specify the user password for the PDF file.
1
  • No problem. Happy to have been of service
    – Shylo Hana
    Oct 15, 2013 at 23:08
0

If your goal is to open the pdf into a terminal, you can use Zathura, but it requires X11 anyway! You can't see a pdf without a properly installed graphical interface.

If you want to open a pdf into another window, you can simply call an external program like evince; in this case, you simply use the terminal to choose the pdf to open and nothing more.

EDIT: I found this link, I think this could solve your problem!

4
  • My requirement is to check if the entered password is can open a the password protected pdf file. I guess i wont be able to do that with evince!!
    – Harsha
    Oct 15, 2013 at 22:37
  • Ops, I have just seen your comment... I think you should study how to create and read a pdf from zero. but in this way it's much more complex...
    – user2848044
    Oct 15, 2013 at 22:39
  • I will try out zathura though!!
    – Harsha
    Oct 15, 2013 at 22:40
  • As you mention zathura requires X, so it's not a solution. If X applications are required, just call the users default PDF viewer using xdg-open file.pdf.
    – Marco
    Oct 15, 2013 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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