Pdf-lib: Find and replace text?

Created on 13 Aug 2020  路  4Comments  路  Source: Hopding/pdf-lib

Reading through the docs.. can't seem to find answer to this

Is there a way to find and replace text?

Here is the use case:

  • I need to generate a lot of PDFs from a template
  • The only thing that changes in each template is a url that is in several places throughout the PDF
  • Is there a way to add a tag like <URL-REPLACEMENT> to the template and then use pdf-lib to find and replace the tag with the actual url?

thanks!

Most helpful comment

I need the same functionnality.
Find a text or an input to fill in the pdf...
Is there a way to do it ?

All 4 comments

I need the same functionnality.
Find a text or an input to fill in the pdf...
Is there a way to do it ?

From what I can see this is not something that is supported by PDF format itself.

I need the same functionnality.
Same solution?

Hello @keyhoffman!

This is possible only if the text you want to find and replace is in a text field (see https://github.com/Hopding/pdf-lib#fill-form). If the text is just normal text on a page and is not in a form field, it is not currently possible (see https://github.com/Hopding/pdf-lib#limitations).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fatso83 picture fatso83  路  3Comments

DanielJackson-Oslo picture DanielJackson-Oslo  路  8Comments

matthopson picture matthopson  路  4Comments

faxemaxee picture faxemaxee  路  6Comments

DanielJackson-Oslo picture DanielJackson-Oslo  路  3Comments