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

609
Visualizações
How to add URLs to work as clickable links in react-pdf

I am generating a pdf using react-pdf library. Everything seems to be working fine but I can't make the Link element from @react-pdf/renderer to work properly.

const add_hyperlink = (url_text: string) => {
  return <Text><Link src={url_text}>{url_text}</Link></Text>;
};

In the pdf document, it appears as a link should and even the pointer changes on hover, on clicking the link, in chrome nothing happens, while in adobe reader, it results in a security block.

I tried to use an <a> tag instead, but it resulted in the same output. Does someone know how to resolve this? Thanks.

EDIT: Something I realized while researching on this. Noting down because it is easy to get confused with the tiny differences.

  1. library @react-pdf/renderer is used to create pdfs in react.
  2. library react-pdf is used to display existing pdf in a react app.

There were several mentions about using annotation options and including "import 'react-pdf/dist/Page/AnnotationLayer.css';" which made links appear properly for many developers. However this belongs to react-pdf library and will only work if it is needed to render pdf within the react-app.

In this case, I am creating a new PDF with @react-pdf/renderer but I am generating a link to download the generated PDF file (https://react-pdf.org/advanced#on-the-fly-rendering).

I found the solution to my problem as well. The link I was using is supposed to redirect to another url, and hence the problem. I used the final link in src and then it works smooth.

I hope these observations are of help to someone in the future :)

about 4 years ago · Juan Pablo Isaza
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