您的位置:首页技术文章

pdftotext —— Linux/Unix中将PDF文件转化为Text文本格式的利器

【字号: 日期:2023-11-12 15:32:37浏览:74作者:馨心
安装 pdftotext 到 RedHat / RHEL / Fedora / CentOS / Ubuntu

在不同的Linux分发版本中使用poppler-utils包安装pdftotext(CentOS):

# yum install poppler-utils

或者在Debian / Ubuntu中使用如下指令:

$ sudo apt-get install poppler-utilspdftotext 使用语法

pdftotext {PDF-file} {text-file}如何将pdf转化为text?

将php-manual.pdf 转化为 php-manual.txt:

$ pdftotext php-manual.pdf php-manual.txt

只转化前 5 页和后 10 页:

$ pdftotext -f 5 -l 10 php-manual.pdf php-manual.txt

转化加密过的pdf文件(owner password ):

$ pdftotext -opw ’password’ php-manual.pdf php-manual.txt

转化加密过的pdf文件(user password ):

$ pdftotext -upw ’password’ php-manual.pdf php-manual.txt

Sets the end-of-line convention to use for text output. You can set it to unix, dos or mac. For UNIX / Linux oses, enter:

$ pdftotext -eol unix php-manual.pdf php-manual.txt更多命令:man page pdftotext

此外,还可以转化pdf为多种其他格式文件:

如可以将pdf文件转化为html,但我测试了一下,效果貌似不佳,很多页面有错乱出现,但是pdftotext转化的效果还是不错的(图片都去掉了),而且速度很快。

标签: Linux系统
相关文章: