pdf 复制文本 乱码

PDF, the ubiquitous document format, is great for sharing documents while preserving fonts, images, and the general layout across platforms. Is there an easy way, however, to preserve that very formatting when copying and pasting text out of the document?

PDF是无处不在的文档格式,非常适合共享文档,同时保留跨平台的字体,图像和总体布局。 但是,在从文档中复制和粘贴文本时,是否有一种简单的方法来保留这种格式?

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader Colen is searching for a way to extract text from PDFs while preserving the formatting:

超级用户阅读器Colen正在寻找一种在保留格式的同时从PDF提取文本的方法:

When I copy text out of a PDF file and into a text editor, it ends up mangled in a variety of ways. Formatting like bold and italics are lost; soft line breaks within a paragraph of text are converted to hard line breaks; dashes to break a word over two lines are preserved even when they shouldn’t be; and single and double quotes are replaced with ? signs.

当我将文本从PDF文件复制到文本编辑器中时,它最终会以各种方式被破坏。 像粗体和斜体这样的格式会丢失; 文本段落中的软换行符转换为硬换行符; 即使在不应该使用破折号的情况下也保留了两行破折号; 单引号和双引号替换为? 迹象。

Ideally, I’d like to be able to copy text from a PDF and have formatting converted to HTML codes, “smart quotes” converted to ” and ‘, and line breaks done properly. Is there any way to do this?

理想情况下,我希望能够从PDF复制文本,并将格式转换为HTML代码,将“智能引号”转换为“和”,并正确完成换行符。 有什么办法吗?

Is there a quick and easy way for Colen (and the rest of us) to get grab text without sacrificing the formatting?

Colen(还有我们其他人)是否有一种快速简便的方法来获取抓取文本而不牺牲格式?

答案 (The Answer)

SuperUser contributor Frabjous offers a solution combined with a heavy dose of caution:

超级用户贡献者Frabjous提供了一种解决方案,并需要特别注意:

Firstly, you have to understand what a PDF is. PDFs are designed to mimic a printed page, and they are designed only as an output format, not an input format. a PDF is basically a map containing the exact location of characters (individual letters or punctuation, etc.) or images. In most cases, a PDF does not even store information about where one word ends and another begins, much less things like soft breaks vs. hard breaks for paragraph endings.

首先,您必须了解什么是PDF。 PDF旨在模仿打印的页面,并且它们仅被设计为输出格式,而不是输入格式。 PDF基本上是一张包含字符(各个字母或标点符号等)或图像的确切位置的地图。 在大多数情况下,PDF甚至不存储有关一个单词的结尾和另一个单词的开头的信息,少了诸如段落结尾的软中断与硬中断之类的信息。

(A few recent PDFs do store some information about this stuff, but that’s a new technology, and you’d be lucky to find PDFs like that. Even if you did, your PDF viewer might not know about it.)

(最近的一些PDF确实存储了有关此内容的一些信息,但这是一项新技术,您很幸运能够找到这样的PDF。即使您这样做,您的PDF查看器也可能不知道它。)

Anyway, it’s up to your software to implement some kind of “artificial intelligence” to extract merely from the locations of individual characters what is a word, what is a paragraph, and so on. Different software is going to do this better than others, and it’s also going to depend on how the PDF was made. In any case, you should never expect perfect results. Having the output PDF is not the same as having the source document. Far better to try to obtain that if you can.

无论如何,要由软件来实现某种“人工智能”,以仅从单个字符的位置提取什么是单词,什么是段落等。 不同的软件将比其他软件做得更好,而且还取决于PDF的制作方式。 无论如何,您永远都不应期望获得完美的结果。 具有输出PDF与具有源文档是不同的。 如果可以的话,尝试获得更好的选择。

The standard solution to your kind of problem is to use Adobe Acrobat Professional (the expensive one, not the free reader) to convert the PDF to HTML. Even that is not going to get perfect results.

解决此类问题的标准方法是使用Adobe Acrobat Professional(价格昂贵,而不是免费的阅读器)将PDF转换为HTML。 即使那样也不会取得完美的结果。

There is free software that can be used to extract text from PDFs with some of formatting intact, but again, don’t expect perfect results. See, e.g., calibre (which can convert to RTF format), pdftohtml/pdfreflow, or the AbiWord word processor (with all import/export plugins enabled). There’s also a PDF import plugin for OpenOffice.

有一些免费软件可用于从PDF中提取格式完整的文本,但同样,不要指望完美的结果。 请参见例如口径(可以转换为RTF格式) , pdftohtml / pdfreflow或AbiWord文字处理器 (启用所有导入/导出插件)。 还有一个用于OpenOffice的PDF导入插件。

But please don’t expect perfection with any of these results. You’re going against the grain here. PDF just is not meant as an editable input format.

但是,请不要指望这些结果中的任何一个都是完美的。 你在这里反对谷物。 PDF并不意味着它是可编辑的输入格式。

If you are having trouble deciding which tool to start with, Calibre is a veritable document Swiss Army knife. You can also use it to convert PDF files for use on your ebook reader and organize your ebook/document library.

如果您在决定使用哪种工具时遇到麻烦,Calibre是名副其实的瑞士军刀。 您还可以使用它来转换PDF文件以在电子书阅读器上使用,以及整理电子书/文档库 。



Have something to add to the explanation? Sound off in the the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不对。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程 。

翻译自: https://www.howtogeek.com/136698/how-can-i-copy-text-from-a-pdf-while-preserving-the-formatting/

pdf 复制文本 乱码

pdf 复制文本 乱码_如何在保留格式的同时从PDF复制文本?相关推荐

  1. excel复制数字乱码_仅在Excel中复制数字

    excel复制数字乱码 Someone emailed me recently, asking how to copy just the numbers, from a column that als ...

  2. excel中 复制工作表_如何在Excel 2013中轻松移动或复制工作表

    excel中 复制工作表 There may be times when you want to create a new Excel worksheet based on an existing w ...

  3. edge打开pdf不显示印章_一旦碰到Edge浏览器打不开pdf文件,只需这样做就可完美解决!...

    近日,系统迷看到有小伙伴求助说,自己win10系统的Edge浏览器打不开pdf文件,一打开,Edge浏览器就会提示错误.一开始还以为是pdf文件的问题,但是去其他电脑上试了,发现pdf文件没有问题. ...

  4. mac与linux文本转换_适用于Windows,Linux和Mac的最佳免费文本编辑器

    mac与linux文本转换 We all use text editors to take notes, save web addresses, write code, as well as othe ...

  5. keil复制代码乱码_成都控制器开发:容易忽略!用KEIL编码汉字也会有BUG

    有时你以为不会有错,但是错误往往出现在意料之外. 那天,用MCU的串口向触摸屏发送汉字字符串,但是在发送某个字符串的时候想要显示的东西总是不能在触屏上正常显示,发送另外的字符串却能正常显示,这就奇了怪 ...

  6. php输出PDF的文件流_怎么用PHP在HTML中生成PDF文件

    译文:使用PHP在html中生成PDF 译者:dwqs 利用PHP编码生成PDF文件是一个非常耗时的工作.在早期,开发者使用PHP并借助FPDF来生成PDF文件.但是如今,已经有很多函数库可以使用了, ...

  7. 文本分析软件_读书笔记:伍多库卡茨质性文本分析:方法、实践与软件使用指南...

    读书笔记:伍多·库卡茨<质性文本分析:方法.实践与软件使用指南> 一.这篇文章.这本书或这篇论文的中心思想.核心观点是什么?核心观点:质性数据如何系统化分析?三大主要方法:主题分析.评估分 ...

  8. 替代微软txt文本编辑器_如何在Microsoft Excel中向对象添加替代文本

    替代微软txt文本编辑器 Alternative text (alt text) allows screen readers to capture the description of an obje ...

  9. 哈工大c语言第四版pdf,C语言程序设计_哈工大(4):指针数组.pdf

    圳 职 业 技 术 学 院Shenzhen Polytechnic 七单元(4):指针数组 教学内容 指针数组及指针数组作main 函数的形式参数 教学目标 应知 指针数组的定义.引用,main 函数 ...

  10. python复制csv数据_如何在python中将数据从一个csv复制到另一个csv?

    熊猫是一个很好的工具,但在这里是过度杀戮.csv模块就足够了,DictReader和DictWriter自动执行您需要的操作: 假设:输入:输出文件模板的第一行中最初包含头 要处理包含输出文件头子集的 ...

最新文章

  1. java static 可见性_Java多线程 synchronized与可见性的关系以及可见性问题总结
  2. python获取用户输入中文_python中的用户输入
  3. 对话实录|华为云.通信云激活无限商业潜力
  4. android 渠道号_亲测:安卓打渠道包神器,1分钟出自动出100个渠道包
  5. php 转义字符处理,PHP转义与反转义字符串函数详解
  6. CV2/PIL/Matplotlib读取图片注意事项
  7. java程序默认使用的xmx_为什么JAVA进程占用内存会超过Xmx设置
  8. MFC对COM接口编写的支持分析
  9. STEP 7 Micro/WIN 指令库下载网址大全s7-200
  10. app live photo_live photo动态壁纸下载-Live Photo动态壁纸app下载 苹果版v2.1-PC6苹果网...
  11. 团队管理之—— 大项目:把握关键点,谋定而后动
  12. 【数字IC】深入浅出理解AXI协议
  13. KOBAS数据库使用指南
  14. 大脑神经网络图高清,图神经网络 图像
  15. 人工神经网络算法与机器算法是相同的算法吗
  16. python matplotlib 绘制堆叠图
  17. 拯救动画卡顿之FLIP
  18. 计算机神书『编码:隐匿在计算机软硬件背后的语言』
  19. #今日论文推荐# DeepMind将范畴论、抽象代数组合,发现GNN与DP之间的联系
  20. 《交通警察》群英传(上)

热门文章

  1. xcode9真机调试
  2. 流畅的python mobi_流畅的Python中文pdf_Python教程
  3. Oracle连接pb,PB内置Oracle数据库接口的使用方法
  4. 8. Andrénalin ★ Serial
  5. android ndk 架构,NDK需要特别注意的armeabi等架构问题
  6. 【疑难解决】将设备通过Ehome协议接入EasyCVR,级联后视频无法播放如何解决?
  7. 苏宁成立快递员节PK京东封杀快递,谁的做法更聪明?
  8. 启动SQL Server服务器以及新建连接的方法
  9. 什么是CAPL编程语言
  10. qq浏览器 广告拦截插件abp_【浏览器插件推荐】如何让QQ浏览器变得更加的高效...