最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to highlight text with PDFJS? - Stack Overflow

programmeradmin2浏览0评论

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 ponents example that renders a page and you can mark the text (.js/tree/master/examples/ponents).

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/patibility.js"></script>

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

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 ponents example that renders a page and you can mark the text (https://github./mozilla/pdf.js/tree/master/examples/ponents).

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/patibility.js"></script>

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

Share Improve this question edited Sep 27, 2016 at 12:02 chocolate cake asked Sep 27, 2016 at 11:01 chocolate cakechocolate cake 2,4797 gold badges29 silver badges58 bronze badges 1
  • 2 Thanks for posting this. Just FYI: "pdf_viewer.js" is not included in the stable release, cloning the pdf.js Github repo and going through the gulp installation will get you the file – bert Commented Aug 11, 2020 at 20:15
Add a ment  | 

1 Answer 1

Reset to default 7

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

How to search for terms you can find here

发布评论

评论列表(0)

  1. 暂无评论