javascript - pdftron 复制错误的文本
问题描述
我想使用pdftron并且一切正常,但是当我从 pdf 复制文本时,一些字符会转换为空白正方形和问号,有什么想法吗?
这是我的pdf。
我写了这段代码:
WebViewer({
path: '/assets/plugins/pdftron',
initialDoc: '/practical.pdf',
fullAPI: true,
disableLogs: true
}, document.getElementById('pdf')).then((instance) => {
// PDFNet is only available with full API enabled
const { PDFNet, docViewer } = instance;
let Feature = instance.Feature;
instance.disableFeatures([Feature.NotesPanel]);
docViewer.on('documentLoaded', () => {
// call methods relating to the loaded document
});
instance.textPopup.add({
type: 'actionButton',
img: '/language.svg',
onClick: () => {
const quads = docViewer.getSelectedTextQuads(docViewer.getCurrentPage());
const text = docViewer.getSelectedText();
$("#out-pdf").html(text);
console.log(quads);
},
});
});
解决方案
文档似乎确实导致提取不正确。PDF 规范没有定义提取,因此每个查看器处理案例的方式都略有不同。在您的情况下,文档中可能包含格式错误或不完整的字体或 unicode 映射。我们为我们的核心组件添加了多个修复程序,并且这些修复程序可以正确提取。不幸的是,当前版本的 WebViewer 还没有包含这些修复。我们无法给出修复将在 WebViewer 上发布的确切时间表,但至少应该是我们下一个主要版本的一部分。现在我会尝试看看你是否可以重新创建文档,看看是否有帮助。我们看到和测试的大多数文档都没有提取问题。
推荐阅读
- swift - 使用泛型参数化属性类型
- pandas - 当索引数据类型为 Pandas 中的 Datetime 时使用索引访问两行?
- r - R ggplot2 轴文本在对数刻度中消失
- c - stm32 如何从 lsm303c i2c 得到答案
- layout - 更改 BigBlueButton HTML 5 客户端布局
- php - 在 docker 容器中启用 mysqli
- sql - 使用 ROW_NUMBER () OVER 获取停止号时出现问题 - DB2
- python - 使用 Python 多处理(Pickle 错误)并行处理具有不可序列化依赖项的函数的正确方法?
- angularjs - 替换 md-select 分隔符
- c# - 动态链接导致注销