Develop a PHP-based library to reside on a web server. It should:
1) Be called with an arbitrary PDF document with forms defined and a name/value array with data to fill
2) Fill the PDF form with the appropriate elements of the data from the array
3) Flatten the PDF with the form
4) Generate a new flattened PDF, save it
5) Merge the new PDF to the end of an existing PDF (extra page at the end)
6) Save the new Merged PDF
First an API should be agreed on, then implemented.
My site is based on PHP/Symfony if that matters.
Sample PDF document to fill attached.