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

163
Views
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
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!