How to run a bash script from a plugin?

Question

I am lookin for some guidance. I have a host command that has to be runned between two functions in a plug-in I am working on.

Long story short,

I have built a class which holds two methods, namely: pdf_handler() and pdf_signer() – Now I realize the names suck.

Within pdf_handler I am filling some form fields in a pdf – all good. In the pdf_signer I need to apply a png image with the user’s signature to that pdf file – can be done.

The problem comes in the flow:
After I fill the form and I save it under a new file I have to import the document again for signing it. On import, the document looses all the form fields including the data within. The solution to this is to ‘flatten’ the form to the pdf, which can be done with pdftk, which is a server/host program.

Short story even shorter,

$this->pdf_handler(); pdftk file.pdf output file_flat.pdf flatten; <---- Unexpected something PHP left the room.$this->pdf_signer();

My question is; How can I execute a bash/cmd script from php, within a wordpress plugin’s class? (I don’t really care about Windows)

0
1 month 2021-05-15T16:59:08-05:00 0 Answers 0 views 0