适用于 Linux 的 CLI pdf 查看器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3570591/
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
CLI pdf viewer for linux
提问by bitmask
Hey, for quite a while now, I am looking for a pdf viewer for the command line.
嘿,很长一段时间以来,我一直在寻找命令行的 pdf 查看器。
As I like to work without X on Linux, and often work on a remote machine, I would like to have a tool to read pdfs. There are quite a lot of really good graphical programs (evince, okular, acroread, ...) to do the job, so I figured there should be at least one decent text-mode tool. But I don't even know of a crappy one!
因为我喜欢在 Linux 上不使用 X 工作,并且经常在远程机器上工作,所以我想要一个阅读 pdf 的工具。有很多非常好的图形程序(evince、okular、acroread 等)可以完成这项工作,所以我认为至少应该有一个不错的文本模式工具。但我什至不知道一个蹩脚的!
Currently, I either start X only to read pdfs, or use pdftohtml+lynx. However, the latter does not produce a very good output, and most documents are just unreadable, especially if they contain mathematical formula.
目前,我要么只启动 X 来阅读 pdf,要么使用 pdftohtml+lynx。然而,后者不会产生很好的输出,而且大多数文档只是不可读,特别是如果它们包含数学公式。
Google is full of people saying either it's not possible or suggesting the pdftohtml version.
谷歌到处都是人说这是不可能的,或者建议使用 pdftohtml 版本。
I realise, this is not exactly a programming question, but I am currently considering starting a project to implement such a program, unless there already is a good one out there.
我意识到,这不完全是一个编程问题,但我目前正在考虑启动一个项目来实现这样的程序,除非已经有一个好的项目。
Thanks for any suggestions.
感谢您的任何建议。
采纳答案by Kasra
Hi I think that you don't need to write a program for your purpose I mean reading pdf file in console mode because "less" command already do it for you. So use it and just enjoy it.
嗨,我认为您不需要为您的目的编写程序我的意思是在控制台模式下阅读 pdf 文件,因为“less”命令已经为您完成了。所以使用它并享受它。
less "the name of pdf file"
少“pdf文件的名称”
回答by Dirk Vollmar
This would only work if your PDF document is structured, i.e. it is a tagged PDFdocument.
这仅适用于您的 PDF 文档是结构化的,即它是一个带标签的 PDF文档。
This is required to get the correct reading-order of the text objects in the document.
这是获得文档中文本对象的正确阅读顺序所必需的。
Tagged PDF documents also allow your to re-flow the document though I am not aware of any tool doing that with command line output.
标记的 PDF 文档还允许您重新处理文档,尽管我不知道有任何工具可以通过命令行输出执行此操作。
回答by Kurt Pfeifle
Ok, you asked to know even "crappy" ones. Here are two (decide yourself about their respective crappiness):
好吧,你甚至要求知道“蹩脚”的。这里有两个(自己决定他们各自的蹩脚):
First: Ghostscript'stxtwrite
output device
第一:Ghostscript的txtwrite
输出设备
gs \
-dBATCH \
-dNOPAUSE \
-sDEVICE=txtwrite \
-sOutputFile=- \
/path/to/your/pdf
Second: XPDF'spdftotext
CLI utility (better than Ghostscript):
第二:XPDF 的pdftotext
CLI 实用程序(比 Ghostscript 更好):
pdftotext \
-f 13 \
-l 17 \
-layout \
-opw supersecret \
-upw secret \
-eol unix \
-nopgbrk \
/path/to/your/pdf
- |less
This will display the page range 13 (first page) to 17 (last page), preserve the layout of a double-password protected named PDF file (using user and owner passwords secretand supersecret), with Unix EOL convention, but without inserting pagebreaks between PDF pages, piped through less...
这将显示页面范围13(˚FIRST页)到17(升AST页面),保留双密码的布局(使用用户和所有者密码保护的名为PDF文件机密和绝密),对Unix EOL惯例,但不在 PDF 页面之间插入分页符,通过较少的管道...
pdftotext -h
displays all available commandline options.
pdftotext -h
显示所有可用的命令行选项。
Of course, both tools only work for the text parts of PDFs (if they have any). Oh, and mathematical formula also won't work too well... ;-)
当然,这两种工具都只适用于 PDF 的文本部分(如果有的话)。哦,数学公式也不会很好用...... ;-)
Edit:I had mis-typed the command above (originally using pdftops
instead of pdftotext
).
编辑:我输错了上面的命令(最初使用pdftops
而不是pdftotext
)。
回答by Giacomo
fbgs maybe could do the trick.
fbgs 也许可以解决问题。
回答by user287424
回答by user3714903
回答by mlwn
By the way, i m always in the same situation, and I use mc (midnight commander) which handles text pdf's very well... Just view the file (F3) in mc
顺便说一句,我总是处于相同的情况,我使用 mc(午夜指挥官),它可以很好地处理文本 pdf ......只需在 mc 中查看文件(F3)