Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight text with PDFJS?

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?

like image 992
chocolate cake Avatar asked Sep 27 '16 11:09

chocolate cake


People also ask

How do I highlight text in highlighter?

Highlight selected text Select the text that you want to highlight. Go to Home and select the arrow next to Text Highlight Color. Select the color that you want.

How do you highlight a PDF in HTML?

Choose Tools > Note Type > Circle, Tools > Note Type > Box, Tools > Note Type > Highlight, Tools > Note Type > Underline, or Tools > Note Type > Strike Out. Select the text you want to highlight or region you want to circle. You can do this repeatedly.


1 Answers

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

How to search for terms you can find here

like image 188
chocolate cake Avatar answered Sep 21 '22 15:09

chocolate cake