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

164
Visualizações
Unable to highlight/select textField after filling it with a value using pdf-lib

I want to dynamically update fields inside some pdf files and use them. For the sake of user experience, I want the fields to be able to be highlighted so it's easier to copy/paste so I don't have to input the values later manually... but I have been unsuccessful in finding a solution.

Here's my code that fills out the textFields using pdf-lib:

const pdf = await PDFLib.PDFDocument.load(filedata);
const form = pdf.getForm();

var textField = form.getTextField(TEXTFIELD_NAME);

textField.setMaxLength(20);

textField.setText("Some value");

textField.enableReadOnly();
const pdfToBytes = await pdf.save();

And then I create a file using "pdfToBytes", but when opening the PDF using any PDF viewer, I'm unable to highlight/select the value inside the textField.

I have tried textField.disableReadonly, but I actually want the field to be read only, and it doesn't really work in all PDF viewers when doing so anyways.

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