我不是要修改PDF,我只是想改变显示的文本
pdf.js输出它在一堆div中读取的文本.textLayer > div,它也绘制了一个画布
我在这里看到,在浏览器中查看和编辑pdf几乎是不可能的,但......
由于pdf.js确实有一个API,我的想法是"挂钩"到pdf.js并更改显示的文本(这在我的情况下绰绰有余)
我能找到的最接近的是这个名为getTextContent()的函数,但是没有回调注册的AFAICS.
这甚至可能(没有弄乱pdf.js本身)?如果是这样,怎么样?
这段代码会将PDF文本打印到控制台中,但如何从这里开始是一个谜.
'use strict';
// In production, the bundled pdf.js shall be used instead of SystemJS.
Promise.all([System.import('pdfjs/display/api'),
System.import('pdfjs/display/global'),
System.import('pdfjs/display/network'),
System.resolve('pdfjs/worker_loader')])
.then(function (modules)
{
var api = modules[0], global = modules[1];
// In production, change this to point to the built `pdf.worker.js` file.
global.PDFJS.workerSrc = modules[3];
// Fetch the PDF document from the URL using promises
let loadingTask = api.getDocument('cv.pdf');
loadingTask.onProgress = function (progressData) …Run Code Online (Sandbox Code Playgroud)我只是想知道 Mozilla 的 pdf.js 是否可以修改 PDF,或者它只是严格用于查看 PDF。