当前位置: 首页 > news >正文

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> 是输出的文本文件路径(可选)。

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

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

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

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

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

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

相关文章:

  • 敏感词 v0.25.0 新特性之 wordCheck 策略支持用户自定义
  • 【安装指南】Chat2DB-集成了AI功能的数据库管理工具
  • 论文阅读笔记——TesserAct: Learning 4D Embodied World Models
  • 【安装指南】Centos7 在 Docker 上安装 RabbitMQ4.0.x
  • 【无需docker】mac本地部署dify
  • AI Rack架构高速互连的挑战:损耗设计与信号完整性的设计框架
  • 在运行 Hadoop 作业时,遇到“No such file or directory”,如何在windows里打包在虚拟机里运行
  • 计算机网络 - stp生成树实验
  • 【现代深度学习技术】现代循环神经网络03:深度循环神经网络
  • MCP 探索:微软 Microsoft MarkItDown MCP ,可把 Word、Excel 等转换成 MarkDown 格式
  • sys目录介绍
  • 基于YOLOV5的目标检测识别
  • 多模态人工智能研究:视觉语言模型的过去、现在与未来
  • 【Git】万字详解 Git 的原理与使用(上)
  • 第 13 届蓝桥杯 C++ 青少组省赛中 / 高级组 2022 年真题
  • 【东枫电子】AMD / Xilinx Alveo™ UL3422 加速器
  • 【愚公系列】《Manus极简入门》012-自我认知顾问:“内在探索向导”
  • Golang 身份证号码校验
  • 【优选算法 | 位运算】位运算基础:深入理解二进制操作
  • ASP.NET MVC​ 入门与提高指南七
  • 郭向阳任广东省公安厅分管日常工作副厅长(正厅级)
  • 69岁朱自强被查,曾任南京地铁总经理
  • 我国首部《人工智能气象应用服务办法》今天发布
  • 王毅:携手做世界和平与发展事业的中流砥柱
  • 新疆维吾尔自治区原质量技术监督局局长刘新胜接受审查调查
  • 北京公园使用指南