在 Chrome 2019 中使用 JS 访问 PDFium 插件方法 [英] Accessing PDFium plugin methods with JS in Chrome 2019

查看:69
本文介绍了在 Chrome 2019 中使用 JS 访问 PDFium 插件方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问 PDFium API,即 Chrome 中的 pdf 查看器.

I would like to access the PDFium API, that is the pdf viewer in Chrome.

不清楚我能做什么.

一些老问题给出了一些提示.

Some old questions give some hints.

pdfium 是否将其 api 暴露给 javascript?我想获取当前页面的数量,但如何做到这一点?

从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆