如何用PDFJS突出显示文本? [英] How to highlight text with PDFJS?

查看:1170
本文介绍了如何用PDFJS突出显示文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个显示其他PDF文件的应用程序。我需要实现一个搜索功能,以便我可以在pdf文件中搜索术语。要显示我正在使用PDFJS的文件。



在pdfjs库中有一些示例,包括呈现页面的组件示例,您可以标记文本( https://github.com/mozilla/pdf.js/tree/master/examples/components )。

但是,当我试图在我的应用程序中使用此代码时,出现 PDFJS.DefaultTextLayerFactory()未定义。我包含以下三个文件:

 < script src =lib / pdfviewer / pdf.js>< / script> ; 
< script src =lib / pdfviewer / pdf.worker.js>< / script>
< script src =lib / pdfviewer / pdf_viewer.js>< / script>
< script src =lib / pdfviewer / compatibility.js>< / script>

我做错了什么?为什么PDFJS不知道 DefaultTextLayerFactory

解决方案

我找到了解决方案。我忘记了包含viewer.js



如何搜索可找到的术语这里


I'm creating an app that shows a PDF file among others. I need to implement a search functionality so that I can search for terms in the pdf file. To display the file I'm using PDFJS.

In the pdfjs library are some examples including the components example that renders a page and you can mark the text (https://github.com/mozilla/pdf.js/tree/master/examples/components).

But when I'm trying to use this code in my app I'm getting the error that PDFJS.DefaultTextLayerFactory() is undefined. I include these three files:

<script src="lib/pdfviewer/pdf.js"></script>
<script src="lib/pdfviewer/pdf.worker.js"></script>
<script src="lib/pdfviewer/pdf_viewer.js"></script>
<script src="lib/pdfviewer/compatibility.js"></script>

What am I doing wrong? Why does PDFJS not know DefaultTextLayerFactory?

解决方案

I found the solution. I forgot to include viewer.js

How to search for terms you can find here

这篇关于如何用PDFJS突出显示文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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