Smart Mailer PHP Support Product Page
Answered
Form to PDF attachment
Asked 10 Apr 2012 16:50:26
1
has this question
10 Apr 2012 16:50:26 aaron bree posted:
Is there a way to get the smart mailer to make the form into a pdf to be mailed as an attachment? Replies
Replied 11 Apr 2012 06:22:51
11 Apr 2012 06:22:51 Vulcho Vulev replied:
Hello Aaron.
You can use the following php script to convert your form to pdf
You can use the following php script to convert your form to pdf
<?php
/*
* createPDF
*
* Takes values submitted via an HTML form and fills in the corresponding
* fields into an FDF file for use with a PDF file with form fields.
*
* @param $file The pdf file that this form is meant for. Can be either
* a url or a file path.
* @param $info The submitted values in key/value pairs. (eg. $_POST)
* @result Returns the PDF file contents for further processing.
*/
function createFDF($file,$info){
$data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ ";
foreach($info as $field => $val){
if(is_array($val)){
$data.='<</T('.$field.')/V[';
foreach($val as $opt)
$data.='('.trim($opt).')';
$data.=']>>';
}else{
$data.='<</T('.$field.')/V('.trim($val).')>>';
}
}
$data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>".
" \n>> \nendobj\ntrailer\n".
"<<\n/Root 1 0 R \n\n>>\n%%EOF\n";
return $data;
}
?>
Replied 16 Apr 2012 22:24:18
16 Apr 2012 22:24:18 aaron bree replied:
Thanks, just two questions. Where exactly does the code go? aND do I choose "attachmnets" tab (and if so what settings) or leave as static text/html?
Replied 24 Sep 2015 06:59:30
24 Sep 2015 06:59:30 arron lee replied:
Thanks for your nice sharing. But I wonder how to deal with those code? Do I need another pdf converter for help? Any suggestion will be appreciated. Thanks in advance.
