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

相关推荐
代码AI弗森16 小时前
PDF OCR + 大模型:让文档理解不止停留在识字
pdf·ocr
小周同学:2 天前
在 Vue2 中使用 pdf.js + pdf-lib 实现 PDF 预览、手写签名、文字批注与高保真导出
开发语言·前端·javascript·vue.js·pdf
Kyln.Wu2 天前
【python实用小脚本-187】Python一键批量改PDF文字:拖进来秒出新文件——再也不用Acrobat来回导
python·pdf·c#
迪尔~3 天前
Apache POI中通过WorkBook写入图片后出现导出PDF文件时在不同页重复写入该图片问题,如何在通过sheet获取绘图对象清除该图片
java·pdf·excel
忆~遂愿3 天前
Python实战教程:PDF文档自动化编辑与图表绘制全攻略
python·pdf·自动化
Rust语言中文社区4 天前
简单好用的在线工具:轻松把图片添加到 PDF
pdf
鲁班AI4 天前
pdf怎么转换成ppt?AI工具与传统方法深度对比
人工智能·pdf·powerpoint
大山运维4 天前
免费专业PDF文档扫描效果生成器
pdf
伊织code5 天前
pdftk - macOS 上安装使用
macos·pdf·pdftk
菜鸟-要努力5 天前
pdf文件转word免费使用几个工具
pdf·word