2
votes

What I currently have:

On form sumbit I call a new php page which executes wkhtmltopdf with the php exec() command by passing it the name of the file the form is in. Ex. (form is in test.php, onsubmit calls complete.php, complete.php has a line exec('wkhtmltopdf test.php test.pdf')) This correctly generates the pdf based on the initial setup of my main page.

The Problem:

My form has checkboxes that show/hides s. It also has a comment box. When I run the wkhtmltopdf on the main php file it only takes the initial setup. I want the wkhtmltopdf to create a pdf with the checkboxes shown and comment fields filled out.

Possible Solutions:

1) On form submit, it would create an identical php file with javascript "hard coding" the selections into the file, thus when wkhtmltopdf calls it the "initial setup" of the page is the filled out page.

2) I've vaguely read that wkhtmltopdf supports using the forms data in the pdf that it makes but it does not work to me. I'd assume that is because I call a new page that then executes the command for wkhtmltopdf. But even if I put it in the same page calling the file, I would assume still grabs the initial condition.

The Question:

So with both of those solutions, I don't know how to do them or if they are even possible. So my question is will either of these work or does someone have a better idea how to do this?

1

1 Answers

1
votes

AFAIK, wkhtmltopdf doesn't have ability to manipulate PDF forms, but you can use PDFtk for that.

So what you're after can be done with a 2-step process: (1) generate the PDF using wkhtmltopdf, then (2) fill out its forms using pdftk.