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
?
- 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
1 Answer
Reset to default 7I found the solution. I forgot to include viewer.js
How to search for terms you can find here