Hey Sakari,
I made you an example. Find the form and PDF template attached.
I'll explain the process step by step.
1) The form is name "TestForm". That is important, because the template must be named in the following pattern FORMNAME_pdf_attachment.php. In my case, it's TestForm_pdf_attachment.php. Save the file in the /media/breezingforms/pdftpl/ folder.
2) The form has eight elements named "Name", "Vorname", "Geburtsdatum", "Strasse", "PLZort", "TelefonPrivat", "TelefonMobil" and "EMail". That is also important, because names of form's elements must match the names in the PDF template file.
3) I deleted all the default lines. I guess you don't need them. The file has the following code:
<?php
$Name = '';
$Vorname = '';
$Geburtsdatum = '';
$Strasse = '';
$PLZort = '';
$TelefonPrivat = '';
$TelefonMobil = '';
$EMail = '';
if (count($xmldata)){
foreach ($xmldata as $data) {
$value = nl2br(htmlentities(substr(is_array($data[_FF_DATA_VALUE]) ? implode('|',$data[_FF_DATA_VALUE]) : $data[_FF_DATA_VALUE],0,10000), ENT_QUOTES, 'UTF-8'));
switch($data[_FF_DATA_NAME]){
case 'Name':
$Name = $value;
break;
case 'Vorname':
$Vorname = $value;
break;
case 'Geburtsdatum':
$Geburtsdatum = $value;
break;
case 'Strasse':
$Strasse = $value;
break;
case 'PLZort':
$PLZort = $value;
break;
case 'TelefonPrivat':
$TelefonPrivat = $value;
break;
case 'TelefonMobil':
$TelefonMobil = $value;
break;
case 'EMail':
$EMail = $value;
break;
}
}
}
?>
<strong>Name: </strong><?php echo $Name; ?><br/>
<strong>Vorname: </strong><?php echo $Vorname; ?><br/>
<strong>Geburtsdatum: </strong> <?php echo $Geburtsdatum; ?><br/>
<strong>Strasse: </strong> <?php echo $Strasse; ?><br/>
<strong>PLZort: </strong><?php echo $PLZort; ?><br/>
<strong>TelefonPrivat: </strong><?php echo $TelefonPrivat; ?><br/>
<strong>TelefonMobil: </strong><?php echo $TelefonMobil; ?><br/>
<strong>EMail: </strong><?php echo $EMail; ?><br/>
First I defined all variables that the template will take from the form. They are initially empty. Then come the IF and FOREACH statement that will take each value from the form and using the SWITCH-CASE statement, each value will be saved in the corresponding variable in the template. After that, all values will be printed in the PDF file.
Test it out. Let me know if you need any modification.
Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on
Facebook!