在Chrome 2019中使用JS访问PDFium插件方法 [英] Accessing PDFium plugin methods with JS in Chrome 2019
问题描述
我想访问PDFium API,即Chrome中的pdf查看器.
I would like to access the PDFium API, that is the pdf viewer in Chrome.
目前尚不清楚我该怎么办.
It is not clear what can I do.
一些老问题给出了一些提示.
Some old questions give some hints.
从javascript调用pdfium(Chrome原生pdf查看器)
我创建了一个HTML文件,但是我发现插件的方法无效.
I created a HTML file but I see that the methods of the plugin are not working.
<html>
<body >
<embed id='embedId' width='100%' height='100%' name='plugin' src='C:\path\file.pdf' type='application/pdf' />
<input type="button" value="Click me" onclick="embedEl=getElementById('embedId'); embedEl.selectAll();">
</body>
</html>
我想知道该API目前是否在Chrome中可用(以便能够在其上构建某些东西).
I would like to know whether the API is available at present time in Chrome (so to be able to build something upon it) or not.
推荐答案
您可以在此处找到一些API方法: https://cs.chromium.org/chromium/src/chrome/browser/resources/pdf/pdf_scripting_api.js
Hi you can find some API methods here: https://cs.chromium.org/chromium/src/chrome/browser/resources/pdf/pdf_scripting_api.js
这是一个基本示例,在加载PDF时会发出警报.
Here is a basic example, it gives out an alert when the PDF loads.
<html>
<body style="overflow:hidden;">
<embed width="100%" height="100%" id="plugin" src="test.pdf" />
<script type="text/javascript" src="pdf_scripting_api.js" />
var plugin = document.getElementById("plugin");
var scriptingAPI = new PDFScriptingAPI(window, plugin);
scriptingAPI.setLoadCallback(function(success)
{
alert(success);
});
</script>
</body>
这篇关于在Chrome 2019中使用JS访问PDFium插件方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!