从javascript调用pdfium(chrome原生pdf查看器)

Fer*_*lez 5 javascript pdf google-chrome google-chrome-extension pdfium

我知道 pdfium 公开了一个 javascript API(请参阅此问题)。但我找不到如何调用这些函数。在带有渲染 PDF 的页面上,我可以看到嵌入标签,但我不知道如何处理它。

var p =  document.getElementsByTagName('embed')[0]
Run Code Online (Sandbox Code Playgroud)

给了我这个:

function anonymous()
 __proto__: Object
 <function scope>
Run Code Online (Sandbox Code Playgroud)

并且在Chrome扩展的源代码中,pdf.js中有这个函数:

  /**
* Handle a scripting message from outside the extension (typically sent by
* PDFScriptingAPI in a page containing the extension) to interact with the
* plugin.
* @param {MessageObject} message the message to handle.
*/
 handleScriptingMessage: function(message) {...}
Run Code Online (Sandbox Code Playgroud)

但它只允许“selectAll”消息。

如果有人能告诉我在哪里可以阅读有关此内容的更多信息或如何使用 javascript 与 pdfium 交互,我将非常感激

Mic*_*ski 1

Lu Wang基于pdf.js的UI为PDFium编写了一个javascript库:PDFium.js的github上的源代码