The easiest way I found to do this is to use:
- Apache FOP (http://fop.apache.org) - it's java
- Do not use the PHP Java class - just use exec or shell_exec to call fop
- Use XSL/T file.
This will create a new PDF file.
To append to an existing PDF file however is a mystery to me because the PDF file is usually compressed and has too many finalized formating already defined. So your best bet is to create a fresh one.