DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

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

I was provided with a pdf file containing placeholder texts: https://drive.google.com/file/d/1jdfde-enJ5_MksYm2CmakNQyLbDNExgE/view?usp=sharing

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…

Top comments (3)

Collapse
 
slimdestro profile image
D\sTro

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

Collapse
 
pcmagas profile image
Dimitrios Desyllas • Edited

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

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

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