How could you dynamically create a pdf within wordpress?

45,857

Solution 1

Take a look at dompdf Its is very easy to use as well as good implementation documentation.

Solution 2

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).

Solution 3

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)

Share:
45,857
user1784593
Author by

user1784593

Updated on July 16, 2022

Comments

  • user1784593
    user1784593 almost 2 years

    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...

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

  • user1784593
    user1784593 over 11 years
    Thanks for the reply. I also saw this, but he never seems to have finished it and it looks like he just disappeared, so it really didnt help much. Thanks anyway.
  • user1784593
    user1784593 over 11 years
    Thanks for the reply, but this plugin is like many others that will take posts and pages and consolidate them and create a pdf. It won't take the entries from a Contact 7 Form and use them to dynamically create a pdf.
  • Fa11enAngel
    Fa11enAngel almost 9 years
    There is a plugin called Gravity PDF, which can be used to generate PDFs from Forms: wordpress.org/plugins/gravity-forms-pdf-extended