PDF转换工具xpdf-tools-4.05

XPDF是一个开源的PDF查看、提取和转换工具套件,使用C++编写,支持多种操作系统,包括Linux、Unix、OS/2、Windows和Mac OS X‌1。XPDF不仅是一个PDF查看器,还包含多个实用工具,如文本提取器、图像转换器和HTML转换器等‌,内置工具包含pdftohtml、pdftotext、pdftopng、pdftops等,支持命令行调用,可实现自主开发程序的自动化。

下面以pdftotext为例,介绍一下将PDF转换为TXT的用法:

一、命令的规则

pdftotext version 4.05 [www.xpdfreader.com]
Copyright 1996-2024 Glyph & Cog, LLC
Usage: pdftotext [options] <PDF-file> [<text-file>]
-f <int> : first page to convert
-l <int> : last page to convert
-layout : maintain original physical layout
-simple : simple one-column page layout
-simple2 : simple one-column page layout, version 2
-table : similar to -layout, but optimized for tables
-lineprinter : use strict fixed-pitch/height layout
-raw : keep strings in content stream order
-fixed <number> : assume fixed-pitch (or tabular) text
-linespacing <number> : fixed line spacing for LinePrinter mode
-clip : separate clipped text
-nodiag : discard diagonal text
-enc <string> : output text encoding name
-eol <string> : output end-of-line convention (unix, dos, or mac)
-nopgbrk : don't insert a page break at the end of each page
-bom : insert a Unicode BOM at the start of the text file
-marginl <number> : left page margin
-marginr <number> : right page margin
-margint <number> : top page margin
-marginb <number> : bottom page margin
-opw <string> : owner password (for encrypted files)
-upw <string> : user password (for encrypted files)
-verbose : print per-page status information
-q : don't print any messages or errors
-cfg <string> : configuration file to use in place of .xpdfrc
-listencodings : list all available output text encodings
-v : print copyright and version info
-h : print usage information
-help : print usage information
--help : print usage information
-? : print usage information

二、参数解释

-layout 选项可以保持原始PDF的布局信息。

-enc UTF-8 指定输出文件的编码为UTF-8。

-f <num> : 指定要转换的起始页码。

-l <num> : 指定要转换的结束页码。

-enc <encoding> : 指定输出文件的编码格式,常用的有UTF-8等。

三、应用实例

  1. 转换PDF为TXT文档。

pdftotxt.exe <input.pdf> [<output.txt>]

其中 <input.pdf> 是源PDF文件的路径, <output.txt> 是输出的文本文件路径(可选)。

  1. 如果PDF包含中文,转换时需指定输出文件的编码格式。

pdftotext -enc UTF-8 input.pdf output.txt

  1. 如果需要保持原始PDF的布局,可以加上-layout 选项。

pdftotext -layout -enc UTF-8 input.pdf output.txt

  1. 指定转换页码的范围。

pdftotxt.exe -layout -enc UTF-8 -f 1 -l 2 input.pdf output.txt

将 input.pdf 的第1页和第2页转换为output.txt。

四、下载地址

PDF转换工具xpdf-tools-win-4.05

PDF转换工具xpdf-tools-linux-4.05

相关推荐
其实秋天的枫2 小时前
考研数学一、二、三历年真题及答案解析PDF电子版(1987-2026年)
经验分享·pdf
WJX_KOI2 小时前
Pandoc —— 解决AI生成的md文档格式转换,安装部署与使用指南(MD转DOCX、PDF等)
人工智能·pdf
Tdsay_2 小时前
在线进行PDF与Base64互转实践指南 —— 浏览器快速处理文档编码数据
pdf·pdf转base64·土豆丝在线工具·base64转pdf
优化控制仿真模型21 小时前
【2026年最新】英语四级历年真题及答案解析PDF电子版(2015-2025年12月)
经验分享·pdf
asdzx671 天前
使用 Python 快速为 PDF 添加背景色或背景图片
python·pdf
其实秋天的枫1 天前
【26年3月最新】计算机二级WPS真题试题及答案14套电子版PDF(含操作题和选择题)
经验分享·pdf
DeskUI~~1 天前
倚天剑术34--批量获取PDF文档中的图片
pdf
河北之花1 天前
演示软件界面及快捷键、幻灯片操作、输出为PDF
pdf·wps
开开心心就好1 天前
安卓免费证件照制作软件,无广告弹窗
linux·运维·安全·pdf·迭代器模式·依赖倒置原则·1024程序员节
YXWik61 天前
Linux 环境 libreoffice 执行word转pdf 中文乱码问题
linux·pdf·word