Click here to Skip to main content
15,916,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
I am working on a project where I am using pdf.js for loading a pdf in my browser and I need to highlight a text in the pdf and this is done on button click, when i click 1st time highlight is not done and if i click for 2nd time the text is highlighted.In my current case i am getting container div id where I need to highlight but I dont get all the div's as the pdf is not rendered in my browser. My question is how to call a page render event in my another highlight.js file.

Please help me for the same.
Thankyou
Posted

1 solution

Try to handle the event which would identify that the pdf is fully loaded and ready. Something like jQuery "ready" event.

Otherwise use setTimeout to delay the function which highlights so that pdf will get loaded during that time.
 
Share this answer
 
Comments
Vandana87 26-Oct-15 2:24am    
hi,
Thankyou for replying.setTimeout did not work i had already tried it.
document.addEventListener('textlayerrendered', function (event) {

if (event.detail.pageNumber === PDFViewerApplication.page) {
Highlight function called here again...
}, true);

In the above snipped I have called textlayerrendered event listner to identify if page is rendered. But the problem is it again fails when I 1st time jump in 2nd page here it highlights text of previous page as the 2nd page is not rendered.

Hope you understood the above issue..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900