DEV Community


How I can replace text in it with a value from a PDF file using PHP?

pcmagas profile image Dimitrios Desyllas ・1 min read

I was provided with a pdf file containing placeholder texts:

In that I want using php to replace the text ${NAME} Into a specified value.

But as long as I searched I found no example on how to do that. Do you have any idea on how to do…


Editor guide
itsmukulmishra profile image
Mukul Mishra

It's simple thing. Use domPDF to parse the file. Store content in some variable and then apply str_replace()

pcmagas profile image
Dimitrios Desyllas Author

Can you provide me an example? Also DOMPdf generates Pdf from html files.

ivanjeremic profile image
Ivan Jeremic

This is easy with JavaScript + ReactJS + react-pdf. But sadly you are in the PHP world.