Link to home
Start Free TrialLog in
Avatar of Greg Alexander
Greg AlexanderFlag for United States of America

asked on

Create a writable PDF and email as an attachement via PHP

I have a writable PDF that I created with Acrobat. Is there any solution that would allow me to submit the actual PDF after the user hits submit. I realize that I could get the $_POST data, but I want to attach the PDF to an email (PHP mail()) and send the actual completed PDF.. Can this be done.. I just need a link to confirmed tutorial or something. Thanks
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Please post a link to the writable PDF you created.  I will see if I can give you an example of how to do this.  Thanks, ~Ray
I use this software: http://www.webassist.com/dreamweaver-extensions/universal-email/

You do have to pay for it, but I think it's worth the money and does everything that I need.
Avatar of Julian Matz
Yes, this is possible. I developed something like this a few months ago. It's a PDF form that you can download, fill in the details, and then press on an embedded submit button. The file is then streamed to a PHP script that attaches it to a mail message and sends it to the recipient. Let me dig up the code I used for it ...
ASKER CERTIFIED SOLUTION
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Greg Alexander

ASKER

Awesome thanks
No bother, glad I could help. I forgot to metion the above script depends on Fileinfo. Fileinfo is included in PHP as of version 5.3 but can be installed as a Pecl extension in earlier versions. This really just checks the file's MIME type, so if you don't have it and don't want to install it, you should be able to create a workaround that doesn't depend on Fileinfo.
I tried this, but am getting en error:

Fatal error: Call to undefined function finfo_open() in /home/content/03/9382403/html/application.php on line 16
alanpowell2007, please see my last comment. You need Fileinfo. If that's not an option, you'll need to use a different method to check the file's MIME type. If you're not using PHP version 5.3 or higher, you can get Fileinfo as a Pecl package:

$ pecl install fileinfo

OR, to make sure that's the right package name:

$ pecl search fileinfo
Thank you.  Right now, I'm just using one pdf file. I took out the whole if statement, and it seems to work. Are there any potential problems with doing this?
I suppose it means that any type of file could be sent to this script, and it would get processed regardless of whether or not the file is a PDF. If you want an alterntive to Fileinfo, maybe something like this would work:

http://www.phpclasses.org/package/922-PHP-Class-for-retrieving-MIME-types-and-extensions-.html