Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
How to highlight text within an iframe using JavaScript while PDF files are within iframe

The pdf document will display in the iframe tag. When the page loads will send one text. In case text is found in the pdf then it should be highlighted in the pdf into the iframe. I am able to show the PDF document in the iframe. But I am not able to find how to highlight the text. Could you please help with this issue using javascript?

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
  <script type="text/javascript">
   
  </script>

<iframe id="myIFrame"  width="100%" height="500px"src = "http://www.africau.edu/images/default/sample.pdf#page=1"; ></iframe>
  </body>
</html>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When you serve a PDF it is no longer yours to edit, it is now in the ownership of the client, and they can edit it their own application/pdf way. Therefore you cannot run JavaScript inside their device it would breach their ownership rights. However Acrobat or other commercial methods may allow you to offer to interact via a fragment such as search.

Chromium variant enter image description here

Safari variant enter image description here

In Acrobat browser Plug-in you can specify #search=word but unless you are an intranet server you can not insist your users are only using Acrobat, or any other paid for solution. But the same function can be used in FireFox (with PDF.js, so not all Mozilla browsers). Thus to trigger highlighting Simple in Firefox change your code to:-

<iframe id="myIFrame"  width="100%" height="500px" src="http://www.africau.edu/images/default/sample.pdf#search=Simple"; ></iframe>

enter image description here

However it does NOT appear to work for more secure Chromium/Edge/Opera etc. and not all FireFox variants may show a PDF, here CyberFox is set to secured.

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!