Printing to PDF

This is possibly a little outside the scope of support, but hopefully someone will have input.

I needed to create a site with the following functions:

1. Lengthy form with file upload capabilities.

2. Ability for end-users to see  and edit only their own forms, with password protection / behind a subscriber wall.

3. Ability to print each form to pdf.

Formidable took care of 1 and 2 quite well, but 3 is obviously a problem (as discussed here and here). None of the available WordPress plugins worked, and the external services (pdfmyurl, etc) weren’t going to work because of the password problem.

What I ended up doing was writing a little tiny plugin to buffer the output of pages displayed and send them through the pdfcrowd.com API. It works, BUT… this is the very first plugin I’ve ever written and it’s really inefficient and I’m sure it could work better.

How I Want It To Work:

When a form is submitted, check to see if the PDF of that entry already exists, delete it if so. Buffer the output of the custom display post and save to a html file on the WP server, send that file (as a file) through the pdfcrowd.com API.

How it is actually working:

Buffering every page view on the site (this isn’t a big deal, I can just clear the cache occasionally. ) Sending all files other than certain named ones – and I need to add to that list – through pdfcrowd.com.

While I’m getting the PDF files I need, I’m getting a lot of extras. I don’t understand how to set up this function so that it ONLY sends Formidable entries through the API – I found the frm_after_create_entry and frm_after_edit_entry hooks, but those don’t seem to work for this since the cache files aren’t generated until the custom display is viewed.

I’m not asking you-the-reader to write code for me – just give me a clue of what function I need to be thinking of or what hook I might base it on. My current code is attached – I can’t send you to the actual site because, like I said, pay wall.  Thank you from a newbie!


Attachment:
formidable-custom-functions formidable-custom-functions.txt

It sounds like you'd need to use the frm_after_create_entry and frm_after_update_entry hooks. I'm not sure on the details of how the pdf creation works, but I think it would be best if it were possible to send a url through your code instead of using the WP header and footer hooks. Have you looked into that possibility?

Yes, I have, but since the URL in question is behind a password, none of the external PDF creation sites work with a URL instead of a file.

Once you get this plugin finished, we can add it to our add-ons page you would like. We get pretty regular requests for this type of functionality and many users may be willing to pay a small fee for an add-on.

I'm not talking about using the external services, I'm talking about modifying your own code. Have you tried it that way? It may require a combination of using WP hooks to allow that url to be accessed by your plugin.

Oh! I see what you mean - use the action hook to start the buffer and make the request. I hadn't tried that, and now I'll have to.  Good idea - I'll let you know if it works.

 

Topic closed.