是否可以检测何时从浏览器PDF查看器打印或下载PDF? [英] Can you detect when a PDF is printed or downloaded from the browser PDF viewer?

查看:266
本文介绍了是否可以检测何时从浏览器PDF查看器打印或下载PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个AngularJS Web应用程序,该应用程序从服务器加载PDF文档,并在页面中显示如下:

We have an AngularJS web app that loads PDF documents from the server and displays them within the page like this:

<object id="preview" type="application/pdf" data="blob:{fileUrl}">

我们有一个新的要求,即只要用户执行某些操作,就必须进行审核:

We have a new requirement to audit whenever a user performs certain actions:

  1. 查看文档(完成)
  2. 打印文档
  3. 下载文档

PDF下载和打印控件位于浏览器PDF查看器中.我们只需要支持最新的Google Chrome浏览器(截至2018年7月为Chrome 68).

The PDF download and print controls are within the browser PDF viewer. We only have to support latest Google Chrome (Chrome 68 as of July 2018).

是否可以检测何时从PDF查看器下载或打印文件?我猜没有看到任何预印/印后事件,因为它是跨源的.我们不需要控制处理程序,只需以某种方式检测事件即可.

Is it possible to detect when the file is downloaded or printed from the PDF viewer? I'm not seeing any beforeprint/afterprint events, I assume because it's cross-origin. We don't need to control the handlers, just detect the events somehow.

推荐答案

您是否尝试过创建自己的pdf查看器?

Have you tried creating your own pdf viewer?

有一些pdf查看器组件,您可以在其中编辑pdf查看器(例如将事件监听器添加到按钮,放置它们等).

There are pdf viewer components readily available where you can edit your pdf viewer(like add event listeners to buttons, position them, etc).

我记得在 pdf.js 的顶部构建一个很久以前.我确信使用pdf.js可以实现所有上述用例.

I remember building one on top of pdf.js in angular a long time ago. I am sure with pdf.js you can implement all the above-mentioned use cases.

这篇关于是否可以检测何时从浏览器PDF查看器打印或下载PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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