Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda