Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false); // // Set font // $this->SetFont('helvetica', 'B', 20); // // Title // $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M'); // } // // // Page footer public function Footer() { } // // Position at 15 mm from bottom // $this->SetY(-15); // // Set font // $this->SetFont('helvetica', 'I', 8); // // Page number // $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); // } // } // }; function mkFrontPDF(){ $comments = str_replace("\n","
",$_POST['comments']); $bankaddress = str_replace("\n","
",$_POST['n_bankaddress']); $address = str_replace("\n","
",$_POST['n_address']); $account_owner = $_POST['owner']; if (!$account_owner) $account_owner = $_POST['realname']; $aw = $_POST; switch ($_POST['banktype']){ case "bank-eu": $aw = "EU-Banküberweisung"; $aw_details = " Kontoinhaber: $account_owner
IBAN: $_POST[iban]
BIC: $_POST[bic]
Bank: $_POST[bankname]

Verwendungszweck:
$_POST[purpose]
"; break; case "bank-noneu": $aw = "Non-EU-Banküberweisung"; $aw_details = " Kontoinhaber: $account_owner
Kontonummer: $_POST[n_iban]
BIC/SWIFT: $_POST[n_bic]
Bank: $_POST[n_ankname]

Bankanschrift:
$bankaddress

Anschrift des Empfängers:
$address

Verwendungszweck:
$_POST[n_purpose]
Anmerkungen:
$comments
"; break; case "bank-paypal": $aw = "PayPal"; $aw_details = "PayPal Account:"; } // create new PDF document $pdf = new kaformPDF( PDF_PAGE_ORIENTATION, PDF_UNIT, $pageLayout /*PDF_PAGE_FORMAT*/, true, 'UTF-8', false); // set document information /* $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); */ // set default header data // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, // PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, // array(0,64,255), array(0,64,128)); // $pdf->setFooterData(array(0,64,0), array(0,64,128)); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('dejavusans', '', 14, '', true); // Add a page // This method has several options, check the source code // documentation for more information. $pdf->AddPage('P'); // set text shadow effect $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); // calculate the overall summary $sum = calcSum(); // Set some content to print $html = <<Kostenerstattungsantrag über $sum EUR

Projekt: $_POST[project]


 
Nickname: $_POST[nickname]
Name: $_POST[realname]
Telefon: $_POST[phone]
E-Mail: $_POST[email]
Ansprechpartner: $_POST[wmdecontact]



Auszahlungsweg: $aw
$aw_details

EOD; //

WMDE Ansprechpartner: $_POST[wmdecontact]

// Telefon: $_POST[phone] // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // --------------------------------------------------------- $tn = tempnam("/tmp","kaform"); // Close and output PDF document // This method has several options, check the source code // documentation for more information. $pdf->Output($tn, 'F'); return $tn; } function mkSnippedPdf($key){ $pageLayout = array(210,70); // create new PDF document # $pdf = new kaformPDF( # PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, # true, 'UTF-8', false); $pdf = new kaformPDF( PDF_PAGE_ORIENTATION, PDF_UNIT, $pageLayout /*PDF_PAGE_FORMAT*/, true, 'UTF-8', false); $pdf->AddPage('L'); $pos = array_search($key,array_keys($_POST['description']))+1; // echo "
Make Snipped for $key -> $pos
"; # $mydesk = $_POST[desc][$key]; # $amount = $_POST['amount'][$key]; $desc = $_POST['description'][$key]; $html = <<Position $pos

$desc


$amount EUR


EOD; // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); $tn = tempnam("/tmp","kaform"); // Close and output PDF document // This method has several options, check the source code // documentation for more information. $pdf->Output("$tn", 'F'); return $tn; } //var_dump($_POST); function convert($row) { $r = array(); foreach ($_SESSION['files'] as $filename => $file){ if ($file['row'] != $row) continue; $tn = tempnam("/tmp","kaform"); file_put_contents("$tn",$file['content']); array_push($r,"$tn"); } return $r; } function calcSum(){ $sum =0; if (!isset($_POST['amount'])) { echo "wrong parameters"; die; } foreach ($_POST['amount'] as $val){ // var_dump($val); $sum += floatval(str_replace(",",".",$val)); } return $sum; } $pdfs = array(); // Applicatoin starts here // $p = mkFrontPDF(); $file = $p; #header('Content-Disposition: attachment; filename="'. basename($file) . '"'); #header('Content-Length: ' . filesize($file)); #readfile($file); #var_dump($p); #die(); #echo "Making Fromt PDF
"; #echo "Did Making Fromt PDF
"; array_push($pdfs,$p); //var_dump($pdfs); foreach ($_POST['description'] as $key => $val) { // echo "DREESK KEY VAL $key --> $val
"; $p = mkSnippedPDF($key); array_push($pdfs,$p); $pr = convert($key); $pdfs = array_merge($pdfs,$pr); } //var_dump($pdfs); // $resultnam = tempnam("/tmp","karesult"); $cmd = "$CONVERT_CMD"; foreach ($pdfs as $filename){ $cmd .= " $filename"; } $cmd .= " cat output $resultnam.pdf"; exec ($cmd); //var_dump($_POST); #echo "CMD: $cmd
"; #die; $file = "$resultnam.pdf"; header('Content-Disposition: attachment; filename="'. basename($file) . '"'); header('Content-Length: ' . filesize($file)); readfile($file);