问题
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