define("FONTSTYLE", "1"); $rep = getRAuftrag($_GET["aid"]); $masch = getAllMaschine($rep["mid"]); $firma = getFirmenStamm($masch["customer_id"]); $hist = getHistory($rep["mid"]); $material = getAllMat($_GET["aid"], $rep["mid"]); if ($material) { foreach ($material as $zeile) { $mat .= $zeile["menge"] . " x " . substr($zeile["description"], 0, 70) . "\n"; } } require "fpdf.php"; require "fpdi.php"; $pdf = new FPDI('P', 'mm', 'A4'); $seiten = $pdf->setSourceFile("vorlage/repauftrag.pdf"); $hdl = $pdf->ImportPage(1); $pdf->addPage(); $pdf->useTemplate($hdl); $pdf->SetFont($repfont, 'B', $repsizeL); $pdf->Text($repname[x], $repname[y], utf8_decode($firma["name"])); $pdf->Text($repstr[x], $repstr[y], utf8_decode($firma["street"])); $pdf->Text($report[x], $report[y], $firma["zipcode"] . " " . utf8_decode($firma["city"])); $pdf->Text($repphone[x], $repphone[y], $firma["phone"]); $pdf->Text($repaid[x], $repaid[y], $_GET["aid"]); $pdf->SetFont($repfont, '', $repsizeN); $pdf->Text($repwvnr[x], $repwvnr[y], $masch['contractnumber']); $pdf->Text($repkdnr[x], $repkdnr[y], $firma["customernumber"]); $pdf->Text($repdate[x], $repdate[y], date("d.m.Y")); $pdf->Text($repmasch[x], $repmasch[y], utf8_decode($masch["description"])); $pdf->Text($repser[x], $repser[y], $masch["serialnumber"]); $pdf->Text($repsort[x], $repsort[y], utf8_decode($masch["standort"]));
function back_id($results) { $this->load->helper('settings'); //print preview of MR $this->load->library('fpdf'); $this->load->library('fpdi'); // initiate FPDI $pdf = new FPDI('L'); // add a page $pdf->AddPage(); // set the sourcefile $pagecount = $pdf->setSourceFile('pdf-report/id/back-id.pdf'); // import page 1 $tplIdx = $pdf->importPage(1); // use the imported page and place it at point 10,10 with a width of 100 mm $pdf->useTemplate($tplIdx); // now write some text above the imported page $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', '', 7); $n = 1; foreach ($results as $result) { $s = new Personal_m(); $row = $s->get_by_employee_id($result->employee_id); //======================== START Column 1 | Right to Left ============================== if ($n == 11) { //add new page $pdf->addPage(); for ($n = 1; $n <= 1; $n++) { $tplidx = $pdf->ImportPage(1); $pdf->useTemplate($tplIdx); //, 1, 1, 210 } $n = $n - 1; } $bday = $row->birth_date; $address = $row->res_address; $blood_type = '"' . $row->blood_type . '"'; $gsis = $row->gsis; $pagibig = $row->pagibig; $philhealth = $row->philhealth; $tin = $row->tin; $emergency = ''; $contact = $row->cp; //----------------------------- Row 1 ---------------------------------- ///Birthday if ($n == 1) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(247, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(257, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(247, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(247, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(247, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(247, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(247, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(235, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(250, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(250); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 2 ---------------------------------- if ($n == 2) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(189, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(199, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(189, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(189, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(189, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(189, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(189, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(177, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(192, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(192); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 3 ---------------------------------- if ($n == 3) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(131, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(141, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(131, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(131, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(131, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(119, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(134, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(134); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 4 ---------------------------------- if ($n == 4) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(73, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(83, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(3); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(73, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(73, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(73, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(61, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(76, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(76); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 5 ---------------------------------- if ($n == 5) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(15, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(25, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(15, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(15, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(15, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(15, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(15, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(3, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(18, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(18); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //======================== END Column 1 | Right to Left ============================== //======================== START Column 2 | Right to Left ============================== //----------------------------- Row 1 ---------------------------------- ///Birthday if ($n == 6) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(247, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(257, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(247, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(247, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(247, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(247, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //TIN $pdf->SetXY(247, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(235, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(250, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(250); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 2 ---------------------------------- //----------------------------- Row 2 ---------------------------------- if ($n == 7) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(189, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(199, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(189, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(189, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(189, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(189, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //tin $pdf->SetXY(189, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(177, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(192, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(192); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 3 ---------------------------------- if ($n == 8) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(131, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(141, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(131, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(131, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(131, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(119, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(134, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(134); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 4 ---------------------------------- if ($n == 9) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(73, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(83, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(3); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(73, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(73, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(73, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(61, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(76, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(76); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 5 ---------------------------------- if ($n == 10) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(15, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(25, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(15, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(15, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(15, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(15, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //tin $pdf->SetXY(15, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(3, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(18, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(18); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //======================== END Column 2 | Right to Left ============================== $n++; } // Output $pdf->Output('pdf-report/back-id.pdf', 'F'); return 'pdf-report/back-id.pdf'; }
/** * Simple helper function which actually merges a given array of document-paths * @param $paths * @return string The created document's url */ private function mergeDocuments($paths) { include_once 'engine/Library/Fpdf/fpdf.php'; include_once 'engine/Library/Fpdf/fpdi.php'; $pdf = new FPDI(); foreach ($paths as $path) { $numPages = $pdf->setSourceFile($path); for ($i = 1; $i <= $numPages; $i++) { $template = $pdf->ImportPage($i); $size = $pdf->getTemplatesize($template); $pdf->AddPage('P', array($size['w'], $size['h'])); $pdf->useTemplate($template); } } $hash = md5(uniqid(rand())); $pdf->Output($hash . '.pdf', "D"); }
function FlyerRendering($inputFile, $outputPostfix, $anschnitt) { /*------------------------------------------------------------------------------------ * Bitte tragt hier eure lokalen Freifunk Daten ein. *------------------------------------------------------------------------------------ * * Hinweiss Community-Logo: * Moegliche Format sind GIF, JPG und PNG. * * Laenge des Community Namen: * Falls der Community-Name zu lang ist und es zu einem Zeilenumbruch kommt, * dann sollte $communityNameFontSize verkleiner werden * -------------------------------------------------------------------------------------*/ // Community Name fuer Hauptseite $communityNameText = "Freifunk Duckburg"; $communityNameFontSize = 48.0; //in pt $communityNamePositionOffsetX = 0.0; // +/- in mm $communityNamePositionOffsetY = 0.0; // +/- in mm // Logo auf Kontaktseite $kontaktLogoDateiName = "logo-template.png"; $kontaktLogoWidth = 66.25; //in mm // Muss kleiner 98.0 mm sein! Hier bitte die gewuenschte Breite des Logos auf dem Flyer eintragen. $kontaktLogoPositionY = 47.0; //in mm // Die Hoeheneinstellung ist etwas frickelig. Es klappt aber :-) // Texte fuer Seite mit Kontaktdaten $kontaktTitelText = "Kontakt"; $kontaktInfoTexte = [["Webseite", "http://ffdb.freifunk.net"], ["Mail", "*****@*****.**"], ["Mailingliste", "*****@*****.**"], ["Twitter", "@FreiFunkDB"], ["Treffen", "Jeden zweiten Montag"], ["", "Und wo? Siehe unsere Webseite"], ["", ""], ["", ""]]; // Text Fusszeile $kontaktFusszeileText = "Freifunk Duckburg e.V."; /*----------------------------------------------------------------------------------- * * Ab hier sollte nichts mehr geander werden! * ------------------------------------------------------------------------------------*/ // Breite der einzelnen Seiten $wRechts = 99.0; //mm $wMitte = 98.0; //mm $wLinks = 97.0; //mm // Community Name $communityNamePositionX = $wLinks + $wMitte + $communityNamePositionOffsetX; //mm $communityNamePositionY = 12.2 + $communityNamePositionOffsetY; //mm // Kontakt Titel $kontaktTitelPositionX = $wLinks + 3.975; //mm $kontaktTitelPositionY = 10.425; //mm $kontaktTitelFontSize = 15.0; //pt // Kontakt Info $kontaktInfoTextPositionX = $kontaktTitelPositionX + 25.0; //mm $kontaktInfoPositionY = $kontaktTitelPositionY + 7.0; //mm $kontaktInfoZeilenOffsetY = 4.7; //mm $kontaktInfoFontSize = 10.9; //pt // Kontakt Logo $kontaktLogoPositionX = $wLinks + $wMitte / 2 - $kontaktLogoWidth / 2; // Kontakt Footer $kontaktFooterPositionX = $wLinks; //mm $kontaktFooterPositionY = 95.40000000000001; //mm $kontaktFooterWidth = $wMitte; //mm $kontaktFooterFontSize = 10.9; //pt echo "\n"; // Output-Dasteiname zusammenbauen $outputFile = $outputPostfix . "-" . $inputFile; // initiate FPDI $pdf = new FPDI(); echo "Input: {$inputFile}\n"; $pageCount = $pdf->setSourceFile($inputFile); // Importiere Vorder- und Rueckseite $Vorderseite = $pdf->ImportPage(1); $Rueckseite = $pdf->ImportPage(2); // Seitenabmessungen holen $size = $pdf->getTemplateSize($Vorderseite); $dokumentBreite = round($size['w'], 2); $dokumentHoehe = round($size['h'], 2); echo "Dokumenten Breite: {$dokumentBreite} mm\n"; echo "Dokumenten Hoehe: {$dokumentHoehe} mm\n"; echo "Anschnitt: {$anschnitt} mm\n"; // Vorderseite uebernehmen // Anfang eines bloeden Hacks wegen des FooterZeilen-Textes. // Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist. // Keine Ahnung warum! $pdf->AddPage('L'); $tplVorderseite = $pdf->importPage(1); $pdf->useTemplate($tplVorderseite); //Margin ist wegen der Rand-Platzierung des Community Names wichtig. $pdf->SetMargins(0, 0, 0); // erstmal alle Fonts laden echo "Lade Fonts...\n"; $pdf->AddFont('lato-bold'); $pdf->AddFont('lato-regular'); $pdf->AddFont('alternategothic'); // Rendern Titel Text echo "Verarbeite Titel Text...\n"; $pdf->SetFont('lato-bold'); $pdf->SetFontSize($kontaktTitelFontSize); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $kontaktTitelText)); // Rendern Info Text echo "Verarbeite Info Text...\n"; $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetFontSize($kontaktInfoFontSize); foreach ($kontaktInfoTexte as $a) { $pdf->SetFont('lato-bold'); $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0])); $pdf->SetFont('lato-regular'); $pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1])); $kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY; } // Rendern Community Logo echo "Verarbeite Logo...\n"; $pdf->Image($kontaktLogoDateiName, $kontaktLogoPositionX + $anschnitt, $kontaktLogoPositionY + $anschnitt, $kontaktLogoWidth, 0); // Rendern Fusszeilen Text echo "Verarbeite Fusszeile...\n"; $pdf->SetFont('lato-regular'); $pdf->SetFontSize($kontaktFooterFontSize); $pdf->SetTextColor(255, 255, 255); //weiss $pdf->SetXY($kontaktFooterPositionX + $anschnitt, $kontaktFooterPositionY + $anschnitt); $pdf->Cell($kontaktFooterWidth, 0, iconv('UTF-8', 'windows-1252', $kontaktFusszeileText), 0, 0, 'C'); // Rendern Community Name echo "Verarbeite Community Name...\n"; $pdf->SetFont('alternategothic'); $pdf->SetFontSize($communityNameFontSize); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($communityNamePositionX + $anschnitt, $communityNamePositionY + $anschnitt); $pdf->MultiCell($wRechts, 10, iconv('UTF-8', 'windows-1252', $communityNameText), 0, 'C'); // Das war's mit dem Editieren // Original PDF Rueckseit uebernehmen $pdf->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf->importPage(2); $pdf->useTemplate($tplRueckseite); // und erstmal abspeichern echo "Zwischenspeichern...\n"; $pdf->Output($outputFile); // Hier geht jetzt der Hack wegen der Footerzeile weiter // Die gerade abgespeicherte Datei wird erneut eingelesen // um dann im Seiten-Format der Ursprungsdatei erneut abgespeichert zu werden. // Is' doof, muss aber sein $pdf_2 = new FPDI(); echo "Erneut laden...\n"; $pageCount = $pdf_2->setSourceFile($outputFile); echo "Feinschliff...\n"; $Vorderseite_2 = $pdf_2->ImportPage(1); $Rueckseite_2 = $pdf_2->ImportPage(2); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplForderseite = $pdf_2->importPage(1); $pdf_2->useTemplate($tplForderseite); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf_2->importPage(2); $pdf_2->useTemplate($tplRueckseite); echo "Output: {$outputFile}\n"; $pdf_2->Output($outputFile); unset($pdf); unset($pdf_2); }
function generatePDF($id_invoice, $introduction_letter = false, $target = 'file', $docs = false) { if (!is_numeric($id_invoice)) { error_log('$id_invoice not defined'); exit(1); } if (!defined('EURO')) { define('EURO', chr(128)); } $facture = Facture::getInfos($id_invoice); foreach (array(LC_MESSAGES, LC_TIME, LC_MONETARY, LC_CTYPE) as $locale) { setlocale($locale, $facture->language . ".UTF-8") or die("locale {$locale} language failed {$facture->language}"); } bindtextdomain('webfinance', dirname(__FILE__) . '/../../lang') or die("Set gettext bindtextdomain language failed\n"); textdomain('webfinance') or die("Set gettext textdomain language failed\n"); $type_doc = $facture->type_doc; if ($facture->language == 'en_US' and $facture->type_doc == 'facture') { $type_doc = 'invoice'; } if ($facture->language == 'en_US' and $facture->type_doc == 'devis') { $type_doc = 'quote'; } // Generate PDF filename $filename = sys_get_temp_dir() . '/' . ucfirst($type_doc) . ' ' . preg_replace('/[^a-z0-9éàçùî\\._-]/i', ' ', $facture->num_facture . ' ' . $facture->nom_client) . '.pdf'; foreach ($facture as $n => $v) { if (!is_array($v)) { $facture->{$n} = preg_replace("/€/", "EUROSYMBOL", $facture->{$n}); // FPDF ne support pas l'UTF-8 $facture->{$n} = utf8_decode($facture->{$n}); $facture->{$n} = preg_replace("/EUROSYMBOL/", chr(128), $facture->{$n}); $facture->{$n} = preg_replace("/\\\\EUR\\{([0-9.,]+)\\}/", "\\1 " . chr(128), $facture->{$n}); } } $pdf = new FPDI('P', 'mm', 'A4'); // Address $address = "{$facture->nom_client}\n"; for ($i = 0; $i < 3; $i++) { $n = sprintf("addr%d", $i + 1); if ($facture->{$n} != "") { $address .= $facture->{$n} . "\n"; } } $address .= "{$facture->cp} {$facture->ville}\n{$facture->pays}"; //Get docs, if needed if ($docs !== false) { $pagecount = $pdf->SetSourceFile(dirname(__FILE__) . '/../admin/invoice_docs/docs_' . $facture->language . '.pdf'); for ($n = 1; $n <= $pagecount; $n++) { $tplidx = $pdf->ImportPage($n, '/MediaBox'); $pdf->AddPage(); $pdf->UseTemplate($tplidx); } } $pdf->SetMargins(10, 10, 10); $pdf->SetDisplayMode('fullwidth'); $pdf->AddPage(); $prefs = new WebfinancePreferences(); // UTF8 to ISO $prefs->prefs['societe']->invoice_top_line1 = preg_replace("/€/", "EUROSYMBOL", $prefs->prefs['societe']->invoice_top_line1); // FPDF ne support pas l'UTF-8 $prefs->prefs['societe']->invoice_top_line1 = utf8_decode($prefs->prefs['societe']->invoice_top_line1); $prefs->prefs['societe']->invoice_top_line1 = preg_replace("/EUROSYMBOL/", chr(128), $prefs->prefs['societe']->invoice_top_line1); // Save the logo to a temp file since fpdf cannot read from a var $tempfile_logo = tempnam(sys_get_temp_dir(), 'logo') . '.png'; $logo_tmp = fopen($tempfile_logo, "w"); fwrite($logo_tmp, $prefs->prefs['logo']); fclose($logo_tmp); // Logo $pdf->Image($tempfile_logo, 90, 5, 25, 0, 'PNG'); // Display text headers $pdf->SetFont('Arial', '', 5); $logo_size = getimagesize($tempfile_logo); $logo_height = $logo_size[1] * 25 / $logo_size[0]; $pdf->SetXY(10, $logo_height + 5); $pdf->Cell(190, 5, $prefs->prefs['societe']->invoice_top_line1, 0, 0, "C"); $pdf->SetLineWidth(0.3); $pdf->SetXY(10, $logo_height + 8); $pdf->Cell(190, 5, utf8_decode($prefs->prefs['societe']->invoice_top_line2), "B", 0, "C"); // Address $pdf->SetFont('Arial', 'B', 11); $pdf->SetXY(115, 50); $pdf->Cell(80, 5, $facture->nom_client, 0, 0); $pdf->SetFont('Arial', '', 11); $y = 54; for ($i = 0; $i < 3; $i++) { $n = sprintf("addr%d", $i + 1); if ($facture->{$n} != "") { $pdf->SetXY(115, $y); $pdf->Cell(80, 5, $facture->{$n}, 0, 0); $y += 5; } } $pdf->SetXY(115, $y); $pdf->Cell(80, 4, $facture->cp . " " . $facture->ville, 0, 0); $pdf->SetXY(115, $y + 5); $pdf->Cell(80, 4, $facture->pays, 0, 0); // Donnees factures $pdf->SetXY(10, 19 + $logo_height); $pdf->SetFont('Arial', 'B', 14); $pdf->Cell(60, 4, ucfirst($type_doc) . utf8_decode(_(' #')) . $facture->num_facture); $pdf->SetFont('Arial', '', 9); $pdf->SetXY(10, 27 + $logo_height); $pdf->Cell(60, 4, $societe->ville . " " . utf8_decode(_("on")) . " " . strftime("%d/%m/%Y", $facture->timestamp_date_facture)); $pdf->SetXY(10, 32 + $logo_height); if (!empty($societe->tva_intracommunautaire)) { $pdf->Cell(60, 4, utf8_decode(_("VAT code")) . " " . $societe->raison_sociale . " : {$societe->tva_intracommunautaire}\n"); } if (!empty($facture->vat_number)) { $pdf->Write(5, utf8_decode(_("Your VAT code")) . " : {$facture->vat_number}\n"); } $pdf->Write(5, $facture->ref_contrat . "\n"); $pdf->Write(5, wordwrap($facture->extra_top, 70)); // Lignes de facturation $pdf->SetLineWidth(0.1); $pdf->SetXY(10, 80); $pdf->SetFont('Arial', 'B', '10'); $pdf->Cell(110, 6, utf8_decode(_("Designation")), 1); $pdf->Cell(20, 6, utf8_decode(_("Quantity")), 1, 0, "C"); $pdf->Cell(30, 6, utf8_decode(_("VAT excl.")), 1, 0, "C"); $pdf->Cell(30, 6, utf8_decode(_("Total")), 1, 0, "C"); $pdf->Ln(); $total_ht = 0; foreach ($facture->lignes as $ligne) { foreach ($ligne as $n => $v) { $ligne->{$n} = preg_replace("/€/", "EUROSYMBOL", $ligne->{$n}); $ligne->{$n} = utf8_decode($ligne->{$n}); $ligne->{$n} = preg_replace("/EUROSYMBOL/", chr(128), $ligne->{$n}); } setlocale(LC_TIME, "fr_FR.UTF8"); // Replace dates like YYYY-MM-DD with nice expanded date $ligne->description = preg_replace_callback('/\\d{4}-\\d{2}-\\d{2}/', create_function('$matches', 'return utf8_decode(strftime("%e %B %Y", strtotime($matches[0])));'), $ligne->description); $y_start = $pdf->getY(); $pdf->SetFont('Arial', '', '10'); $pdf->MultiCell(110, 6, $ligne->description, "LR", 'L'); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->setXY(120, $y_start); $pdf->Cell(20, 6, $ligne->qtt, "LR", 0, "C"); $pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $ligne->prix_ht)), "LR", 0, "R"); $pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $ligne->prix_ht * $ligne->qtt)), "LR", 0, "R"); $pdf->setXY(120, $y_start); $pdf->Cell(20, $y - $y_start, '', "LR", 0, "C"); $pdf->Cell(30, $y - $y_start, '', "LR", 0, "R"); $pdf->Cell(30, $y - $y_start, '', "LR", 0, "R"); $total_ht += $ligne->prix_ht * $ligne->qtt; $pdf->Ln(); $pdf->Cell(110, 2, "", "LR"); $pdf->Cell(20, 2, "", "LR"); $pdf->Cell(30, 2, "", "LR"); $pdf->Cell(30, 2, "", "LR"); $pdf->Ln(); } $y_fin = $pdf->getY(); if ($y < 190) { $pdf->Cell(110, 190 - $y, "", "LRB", 0, "C"); $pdf->Cell(20, 190 - $y, "", "LRB", 0, "C"); $pdf->Cell(30, 190 - $y, "", "LRB", 0, "C"); $pdf->Cell(30, 190 - $y, "", "LRB", 0, "C"); $pdf->Ln(); } // Total HT $txt_type_paiement = $facture->type_paiement; if (preg_match('/eption de cette facture/', $txt_type_paiement) and $facture->language != 'fr_FR') { $txt_type_paiement = _('upon receipt of invoice'); } $pdf->SetFont('Arial', '', '11'); $pdf->Cell(130, 6, utf8_decode(_("Payment")) . " : " . $txt_type_paiement); $pdf->Cell(30, 6, utf8_decode(_("Subtotal")), "", 0, "R"); $pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $total_ht)), "", 0, "R"); $pdf->Ln(); // TVA $pdf->Cell(130, 6, ""); $pdf->Cell(30, 6, utf8_decode(_("VAT")) . " " . str_replace('.', ',', $facture->taxe) . "%", "", 0, "R"); $pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $facture->taxe / 100 * $total_ht)), "", 0, "R"); $pdf->Ln(); // Solde à régler $pdf->SetFont('Arial', 'B', '11'); $pdf->Cell(130, 6, ""); $pdf->Cell(30, 6, utf8_decode(_('Total')), "", 0, "R"); $pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, (1 + $facture->taxe / 100) * $total_ht - $facture->accompte)), "", 0, "R"); $pdf->Ln(); $pdf->Ln(); $pdf->SetFont('Arial', '', '8'); $pdf->MultiCell(190, 4, utf8_decode(_('Discount not practiced by the company. In case of default in the invoice due date, the client agrees to pay a penalty pursuant to the provisions of Article 1226 of the Civil Code, an increase of 15% in addition to the main total without any notice of default being required.'))); // Extra data $pdf->SetFont('Arial', '', '10'); if (!empty($facture->extra_bottom)) { $pdf->Ln(10); $pdf->MultiCell(120, 6, $facture->extra_bottom, 0); } // RIB $result = mysql_query('SELECT value ' . 'FROM webfinance_pref ' . 'WHERE id_pref=' . $facture->id_compte) or die(mysql_error()); list($cpt) = mysql_fetch_array($result); mysql_free_result($result); $cpt = unserialize(base64_decode($cpt)); if (!is_object($cpt)) { echo "compte Impossible de generer la facture. <a " . "href='../admin/societe'>Vous devez saisir au moins un compte " . "bancaire dans les options pour emettre des factures</a>"; exit(1); } foreach ($cpt as $n => $v) { $cpt->{$n} = utf8_decode($cpt->{$n}); } $pdf->SetFont('Arial', 'B', '10'); $pdf->Ln(); $pdf->Cell(160, 6, utf8_decode(_("Bank references")) . " ", "LTR", 0, "C"); $pdf->Ln(); $pdf->SetFont('Arial', '', '8'); $pdf->Cell(35, 6, utf8_decode(_("Bank")) . " : ", "L"); $pdf->Cell(125, 6, $cpt->banque, "R"); $pdf->Ln(); $pdf->Cell(35, 6, "IBAN : ", "L"); $pdf->Cell(125, 6, $cpt->iban, "R"); $pdf->Ln(); $pdf->Cell(35, 6, "SWIFT/BIC : ", "LB"); $pdf->Cell(125, 6, $cpt->swift, "BR"); $pdf->Ln(); $pdf->SetAuthor($societe->raison_sociale); $pdf->SetCreator('Webfinance $Id: gen_facture.php 532 2012-11-10 10:32:19Z pierre $ Using FPDF'); $pdf->SetSubject(ucfirst($facture->type_doc) . utf8_decode(_(' #')) . " " . $facture->num_facture . " " . utf8_decode(_("for")) . " " . $facture->nom_client); $pdf->SetTitle(ucfirst($facture->type_doc) . utf8_decode(_(' #')) . " " . $facture->num_facture); if ($target == 'file') { $pdf->Output($filename, 'F'); } else { $pdf->Output(basename($filename), 'I'); } $pdf->Close(); // Delete temporary logo file unlink($tempfile_logo); global $language; foreach (array(LC_MESSAGES, LC_TIME, LC_MONETARY, LC_CTYPE) as $locale) { setlocale($locale, $language . ".UTF-8") or die("locale {$locale} language failed {$language}"); } bindtextdomain('webfinance', dirname(__FILE__) . '/../../lang') or die("Set gettext bindtextdomain language failed\n"); textdomain('webfinance') or die("Set gettext textdomain language failed\n"); return $filename; }
function FlyerRendering($config, $inputFile, $outputPath, $outputPostfix, $anschnitt = 0.0) { // Breite der einzelnen Seiten $wRechts = 99.0; //mm $wMitte = 98.0; //mm $wLinks = 97.0; //mm // Community Name $communityNamePositionX = $wLinks + $wMitte + $config['communityNamePositionOffsetX']; //mm $communityNamePositionY = 12.2 + $config['communityNamePositionOffsetY']; //mm // Kontakt Titel $kontaktTitelPositionX = $wLinks + 3.975; //mm $kontaktTitelPositionY = 10.425; //mm $kontaktTitelFontSize = 15.0; //pt // Kontakt Info $kontaktInfoTextPositionX = $kontaktTitelPositionX + 25.0; //mm $kontaktInfoPositionY = $kontaktTitelPositionY + 7.0; //mm $kontaktInfoZeilenOffsetY = 4.7; //mm $kontaktInfoFontSize = 10.9; //pt // Kontakt Logo $kontaktLogoPositionX = $wLinks + $wMitte / 2 - $config['kontaktLogoWidth'] / 2; // Kontakt Footer $kontaktFooterPositionX = $wLinks; //mm $kontaktFooterPositionY = 95.40000000000001; //mm $kontaktFooterWidth = $wMitte; //mm $kontaktFooterFontSize = 10.9; //pt // Output-Dasteiname zusammenbauen $outputFile = $outputPath . DIRECTORY_SEPARATOR . $outputPostfix . '_' . basename($inputFile); // initiate FPDI $pdf = new FPDI(); echo 'Input: ' . basename($inputFile) . PHP_EOL; $pageCount = $pdf->setSourceFile($inputFile); // Importiere Vorder- und Rueckseite $Vorderseite = $pdf->ImportPage(1); $Rueckseite = $pdf->ImportPage(2); // Seitenabmessungen holen $size = $pdf->getTemplateSize($Vorderseite); $dokumentBreite = round($size['w'], 2); $dokumentHoehe = round($size['h'], 2); echo 'Dokumenten Breite: ' . $dokumentBreite . 'mm' . PHP_EOL; echo 'Dokumenten Hoehe: ' . $dokumentHoehe . 'mm' . PHP_EOL; echo 'Anschnitt: ' . $anschnitt . 'mm' . PHP_EOL; // Vorderseite uebernehmen // Anfang eines bloeden Hacks wegen des FooterZeilen-Textes. // Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist. // Keine Ahnung warum! $pdf->AddPage('L'); $tplVorderseite = $pdf->importPage(1); $pdf->useTemplate($tplVorderseite); //Margin ist wegen der Rand-Platzierung des Community Names wichtig. $pdf->SetMargins(0, 0, 0); // erstmal alle Fonts laden echo 'Lade Fonts...' . PHP_EOL; $pdf->AddFont('lato-bold'); $pdf->AddFont('lato-regular'); $pdf->AddFont('alternategothic'); // Rendern Titel Text echo 'Verarbeite Titel Text...' . PHP_EOL; $pdf->SetFont('lato-bold'); $pdf->SetFontSize($kontaktTitelFontSize); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $config['kontaktTitelText'])); // Rendern Info Text echo 'Verarbeite Info Text...' . PHP_EOL; $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetFontSize($kontaktInfoFontSize); foreach ($config['kontaktInfoTexte'] as $a) { $pdf->SetFont('lato-bold'); $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0])); $pdf->SetFont('lato-regular'); $pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1])); $kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY; } // Rendern Community Logo echo 'Verarbeite Logo...' . PHP_EOL; $pdf->Image($config['kontaktLogoDateiName'], $kontaktLogoPositionX + $anschnitt, $config['kontaktLogoPositionY'] + $anschnitt, $config['kontaktLogoWidth'], 0); // Rendern Fusszeilen Text echo 'Verarbeite Fusszeile...' . PHP_EOL; $pdf->SetFont('lato-regular'); $pdf->SetFontSize($kontaktFooterFontSize); $pdf->SetTextColor(255, 255, 255); //weiss $pdf->SetXY($kontaktFooterPositionX + $anschnitt, $kontaktFooterPositionY + $anschnitt); $pdf->Cell($kontaktFooterWidth, 0, iconv('UTF-8', 'windows-1252', $config['kontaktFusszeileText']), 0, 0, 'C'); // Rendern Community Name echo 'Verarbeite Community Name...' . PHP_EOL; $pdf->SetFont('alternategothic'); $pdf->SetFontSize($config['communityNameFontSize']); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($communityNamePositionX + $anschnitt, $communityNamePositionY + $anschnitt); $pdf->MultiCell($wRechts, 10, iconv('UTF-8', 'windows-1252', $config['communityNameText']), 0, 'C'); // Das war's mit dem Editieren // Original PDF Rueckseit uebernehmen $pdf->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf->importPage(2); $pdf->useTemplate($tplRueckseite); // und erstmal abspeichern echo 'Zwischenspeichern...' . PHP_EOL; $pdf->Output($outputFile); // Hier geht jetzt der Hack wegen der Footerzeile weiter // Die gerade abgespeicherte Datei wird erneut eingelesen // um dann im Seiten-Format der Ursprungsdatei erneut abgespeichert zu werden. // Is' doof, muss aber sein $pdf_2 = new FPDI(); echo 'Erneut laden...' . PHP_EOL; $pageCount = $pdf_2->setSourceFile($outputFile); echo 'Feinschliff...' . PHP_EOL; $Vorderseite_2 = $pdf_2->ImportPage(1); $Rueckseite_2 = $pdf_2->ImportPage(2); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplVorderseite = $pdf_2->importPage(1); $pdf_2->useTemplate($tplVorderseite); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf_2->importPage(2); $pdf_2->useTemplate($tplRueckseite); echo 'Output: ' . basename($outputFile) . PHP_EOL; $pdf_2->Output($outputFile); unset($pdf); unset($pdf_2); }
include "inc/FirmenLib.php"; include "inc/wvLib.php"; include "inc/pdfpos.php"; define("FPDF_FONTPATH", "/usr/share/fpdf/font/"); define("FONTART", "2"); define("FONTSTYLE", "1"); $rep = suchVertrag($_GET["aid"]); $rep = $rep[0]; $masch = getVertragMaschinen($rep["cid"]); $firma = getFirmenStamm($rep["customer_id"]); require "fpdf.php"; require "fpdi.php"; $pdf = new FPDI('P', 'mm', 'A4'); $seiten = $pdf->setSourceFile("vorlage/wv" . $rep["template"]); $ende = $rep["endedatum"] == $rep["anfangdatum"] ? "offen" : db2date($rep["endedatum"]); $hdl = $pdf->ImportPage(1); $pdf->addPage(); $pdf->useTemplate($hdl); $pdf->SetFont($wvfont, '', $wvsize); $pdf->Text($wvname[x], $wvname[y], utf8_decode($firma["name"])); $pdf->Text($wvstr[x], $wvstr[y], utf8_decode($firma["street"])); $pdf->Text($wvort[x], $wvort[y], $firma["zipcode"] . " " . utf8_decode($firma["city"])); $pdf->Text($wvkdnr[x], $wvkdnr[y], $firma["customernumber"]); $pdf->Text($wvwvnr[x], $wvwvnr[y], $rep['contractnumber']); $pdf->Text($wvstart[x], $wvstart[y], db2date($rep["anfangdatum"])); $pdf->Text($wvende[x], $wvende[y], $ende); $pdf->Text($wvbetrag[x], $wvbetrag[y], sprintf("%0.2f", $rep["betrag"])); $pdf->SetFont('Helvetica', '', 10); $bem = $rep["bemerkung"] ? utf8_decode($rep["bemerkung"]) : "Es werden keine Sondervereinbarungen getroffen"; $pdf->SetY($wvbem[y]); $pdf->SetX($wvbem[x]);