Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda