How could you dynamically create a pdf within wordpress?

I’m using a Contact Form 7 to have the users enter data, then based on their data entry, I need to add different text to the pdf before outputting the entire pdf.

For example, if the user says they like red balloons, the created balloon pdf will mention how important red balloons are, etc…

Read More

I know there must be a way to do this using fpdf, tcpdf, or something, but I’m not sure how. Any ideas?

Related posts

Leave a Reply

5 comments

  1. You may wish to use PHP’s native PDF functions wrapped in a custom WordPress plugin to generate your own PDF documents. Check out the PHP.net Manual: PDF for an overview. I’m there there are plenty of PHP=>PDF vendor libraries out there if you search the Google’s.

    Another solution, off the top of my head, would be to run a worker process somewhere to convert and return documents in [?|PDF] formats based on WordPress data fed through a template system (mustache, twig, etc).

  2. First of all I really recommend using Gravity Forms, it’s a better plugin for forms and it also saves entries in the database so you can retrieve them.

    For the PDF part, I think you need to program it manually.

    Create a php file that implements tcpdf, and receives all input from the form (via POST or GET). Then you have all the parameters you need and you can create the PDF in any way you like.

    In order to use this php file, open a Page in WordPress and then rename the php file to page-.php (where XXXX is the new Page ID you opened)