How to highlight text with PDFJS?

被刻印的时光 ゝ 提交于 2019-12-12 11:04:46

问题


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?


回答1:


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

How to search for terms you can find here



来源:https://stackoverflow.com/questions/39722961/how-to-highlight-text-with-pdfjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!