Question : 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

Answer : Create a writable PDF and email as an attachement via PHP

Below is a PHP script you can use to process and mail the PDF. As far as I remember, you'll need Adobe LiveCycle Designer to create your PDF and apply the correct permissions. Let me know if you need help with that also.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
<?php

error_reporting(E_ALL|E_STRICT);

$r = $_REQUEST;

$string = '';

$postdata = file_get_contents('php://input');
$name = 'PDF_form_'.date('Ymd_his').'_'.rand(1000,9999).'.pdf';
$file = "/tmp/$name"; //needs to be writable
$f = fopen( $file, 'w' );
fwrite( $f, $postdata );
fclose($f);

$finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension
$info = finfo_file($finfo,$file);
finfo_close($finfo);

if ( $info !== 'application/pdf' )
{
	@unlink($file);
	die("Error: the file type you have submitted ($info) is not valid.");
}

$pdf = wordwrap(base64_encode($postdata),72,"\n",true);

$recipient = '[email protected]';
$cc = '[email protected]';
$sender = '[email protected]';
$subject = 'PDF Form';
$boundary = '==Multipart_Mix_x'.md5(rand(1000,9999)).'x';

$headers = "From: $sender\n";
$headers .= "Cc: $cc\n";
$headers .= "X-Mailer: NetLink IT Services\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'."\n\n";

$message = <<<__MESSAGE__

This is a multi-part message in MIME format.
--{$boundary}
Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

Application form attached. For support, please contact support @ netlink.ie.

--{$boundary}
Content-Type: application/pdf;
 name="{$name}"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="{$name}"

{$pdf}

--{$boundary}--

__MESSAGE__;

mail($recipient,$subject,$message,$headers);

header('Content-type: application/vnd.fdf');

?>
%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF
	<<
	/Status(Thank you. Your details have been submitted and someone will get in touch with you regarding your application.)
	>>
>>
endobj
trailer
<</Root 1 0 R>>
%%EOF
Random Solutions  
 
programming4us programming4us