javascript - 为什么从 PDF 复制时缺少格式

标签 javascript pdf clipboard onedrive summernote

我正在使用 Summernote 编辑器,从 PDF 文档复制和粘贴时它缺少格式。

所有其他编辑器(例如 google doc 和 onedrive doc)中都存在此问题。

但从 PDF 文档复制和粘贴时,msWord 会保留格式。

任何人都了解 MS WORD 是如何做到这一点的,因为从 PDF 复制时剪贴板不会保留任何 html 标签?

粘贴数据时我检查了剪贴板。它显示了以下仅包含 div 标签的结果。

<div>This is Heading1 Text</div><div>This is a regular paragraph with the default style of Normal. This is a regular paragraph with the default style of Normal. This is a regular paragraph with the default style of Normal. This is a regular paragraph with the default style of Normal. This is a regular paragraph with the default style of Normal.</div><div>This is a Defined Block Style Called BlockStyleTest</div><div>This is more Normal text.</div><div>This is Heading 2 text</div><div>This is more Normal text. This is bold, this is italic, and this is bold italic. This is normal. This is in a defined inline style called InlineStyle. This is normal. This is red text. This is normal.</div><div>This block is centered.</div><div>This is left-aligned.</div><div> First item of bulleted list.</div><div> Second item of bulleted list.</div><div>Second paragraph of second item of bulleted list.</div><div> Third item of bulleted list.</div><div>o First item of third item’s nested list</div><div>o Second item of third item’s nested list</div><div> Fourth and final item of main bulleted list.</div><div>This is Normal text.</div><div>1. First item of numbered list.</div><div>2. Second item of numbered list.</div><div>Second paragraph of second item of numbered list.</div><div>3. Third item of numbered list.</div><div>Here is a BMP picture:</div><div>Here is a JPEG picture:</div><div>Here is a PNG picture:</div><div>Here is a table:</div><div>New York Boston Detroit</div><div>Baseball Mets Yankees Red Sox Tigers</div><div>Hockey Rangers Islanders Bruins Red Wings</div><div>Football Giants Jets Patriots Lions</div><div>Here is an embedded Excel spreadsheet:</div><div>pre- post- pre- postdogs</div><div>1234.43 0.33 354.30 777.00</div><div>cats 432.00 -432.20 654.45 333.00</div><div>turkeys 3.30 4.66 34.65 132.10</div><div>fish 52.55 55.33 37.88 31.50</div><div>total 1722.28 -371.88 1081.28 1273.60</div><div>2001 2002</div><div>https://en.wikipedia.org/wiki/United_States</div><div>This is more Underlined text.</div><div>This is more Strikethrough text.</div><div>Test superscript text. This is superscript texts.</div><div>Test subscript text. This is subscript texts.</div><div>Here are some special characters -!”&amp;’(*)+’./:;?_ÈÓ 12\</div><div>This concludes our test.</div>

最佳答案

PDF 使用 PostScript,看来您在从 PostScript 复制和粘贴到“Summernote”等时遇到问题。MS Word 显然多年来花了很多时间来与 PostScript 很好地配合,必须有 Word 用来实现它的信息是 PostScript 并正确处理粘贴。

顺便说一句,PostScript 比看起来要复杂得多。

背景信息: https://youtu.be/48tFB_sjHgY https://youtu.be/guXgBe2wvEA https://youtu.be/-cFOsAzigyQ https://youtu.be/S_NXz7I5dQc

解决方法: 您可以尝试直接从 Word 打开 PDF,然后复制并粘贴到 Summernote 中。 (我还没有验证这是否有效)

结论: 我看不出有什么方法可以解决您的问题,因为这完全取决于接收程序,在您的情况下是 Summernote 和其他程序。

关于javascript - 为什么从 PDF 复制时缺少格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41583349/

相关文章:

linux - 向现有 PDF 文件添加裁剪标记

java - 添加 PDF 撤销信息作为签名属性 pdfRevocationInfoArchival OID 1.2.840.113583.1.1.8

html - 如何仿Bootstrap的html代码高亮复制到剪贴板?

javascript - AutoPostBack 导致隐藏的 div 崩溃

javascript - 尝试从 pdf 解压缩外部参照流 - 获取 "ERROR incorrect header check"

Javascript 阅读文档和 PDF

java - 为什么重启程序后DataFlavors变了?

python - 使用单个 Python 脚本从 Linux、Mac 和 Windows 上的剪贴板复制数据

javascript - 无法创建 Preloadjs 实例

javascript - 为弹出窗口创建标题