在 bash 脚本中打开 pdf 文件的命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19391971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:18:55  来源:igfitidea点击:

Command to open pdf files in bash scripting

linuxbashunixpdfubuntu

提问by Harsha

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.

任何人都可以建议我在命令行上打开 pdf 文件(仅限文本)的任何简单的 linux 命令。如果我们能够将密码作为参数传递给命令,那将更受欢迎。

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

我正在尝试构建一个迭代所有可能的 4 个字符密码的脚本,以破解受密码保护的 pdf 文件的密码。

Thanks in Advance Harsha

提前致谢 Harsha

采纳答案by m51

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.

如果您的目标是将 pdf 文件打开到终端中,您可以使用Zathura,但无论如何它都需要 X11!如果没有正确安装图形界面,您将看不到 pdf。

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.

如果你想打开一个 pdf 到另一个窗口,你可以简单地调用一个像evince这样的外部程序;在这种情况下,您只需使用终端选择要打开的 pdf,仅此而已。

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

编辑:我找到了这个链接,我认为这可以解决您的问题!

回答by Marco

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:

要在终端上阅读 PDF,您可以使用帧缓冲 PDF 查看器,如 fbgs(基于 fbi 图像查看器和 gs)。从主页

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

fbgs:使用 fbi 在 framebuffer 控制台上查看 ps/pdf 文件的包装脚本。

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

如果允许 X 应用程序,只需调用用户默认的 PDF 查看器使用

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.

如果您想做进一步的 PDF 操作,请查看pdftk,它允许设置密码和更多功能。

回答by Shylo Hana

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 是 xpdf 包的一部分。它将输出到文本文件。如果未指定输出文件,您将得到一个同名文件,但扩展名为“.txt”。

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.