public function testPdfOutput() { $this->markTestIncomplete('Transparency rendering on signature not working.'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 052'); $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 . ' 052', PDF_HEADER_STRING); // 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) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- /* NOTES: - To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt - To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12 - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes */ // set certificate file $certificate = 'file://tests/data/cert/tcpdf.crt'; // set additional information $info = array('Name' => 'TCPDF', 'Location' => 'Office', 'Reason' => 'Testing TCPDF', 'ContactInfo' => 'http://www.tcpdf.org'); // set document signature $pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info); // set font $pdf->SetFont('helvetica', '', 12); // add a page $pdf->AddPage(); // print a line of text $text = 'This is a <b color="#FF0000">digitally signed document</b> using the default (example) <b>tcpdf.crt</b> certificate.<br />To validate this signature you have to load the <b color="#006600">tcpdf.fdf</b> on the Arobat Reader to add the certificate to <i>List of Trusted Identities</i>.<br /><br />For more information check the source code of this example and the source code documentation for the <i>setSignature()</i> method.<br /><br /><a href="http://www.tcpdf.org">www.tcpdf.org</a>'; $pdf->writeHTML($text, true, 0, true, 0); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // *** set signature appearance *** // create content for signature (image and/or text) $pdf->Image('tests/images/tcpdf_signature.png', 180, 60, 15, 15, 'PNG'); // define active area for signature appearance $pdf->setSignatureAppearance(180, 60, 15, 15); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // *** set an empty signature appearance *** $pdf->addEmptySignatureAppearance(180, 80, 15, 15); $this->comparePdfs($pdf); }
function student_kolizijapdf() { global $userid; require_once 'lib/tcpdf/tcpdf.php'; $semestar = intval($_REQUEST['semestar']); if ($semestar == 1) { $tekst_semestar = "zimskom"; } else { $tekst_semestar = "ljetnjem"; } // Prikupljam podatke iz baze // Za koju godinu se prijavljuje? $q1 = myquery("select id, naziv from akademska_godina where aktuelna=1"); $q2 = myquery("select id, naziv from akademska_godina where id>" . mysql_result($q1, 0, 0) . " order by id limit 1"); if (mysql_num_rows($q2) < 1) { // nicemessage("U ovom trenutku nije aktiviran upis u sljedeću akademsku godinu."); // return; // Pretpostavljamo da se upisuje u aktuelnu? $zagodinu = mysql_result($q1, 0, 0); $agnaziv = mysql_result($q1, 0, 1); $q3 = myquery("select id from akademska_godina where id<{$zagodinu} order by id desc limit 1"); $proslagodina = mysql_result($q3, 0, 0); } else { $proslagodina = mysql_result($q1, 0, 0); $zagodinu = mysql_result($q2, 0, 0); $agnaziv = mysql_result($q2, 0, 1); } // Koji je odsjek? $q4 = myquery("select s.id, s.naziv, i.naziv, ss.semestar from studij as s, student_studij as ss, institucija as i where ss.student={$userid} and ss.studij=s.id and s.institucija=i.id and ss.akademska_godina={$proslagodina} order by semestar desc limit 1"); if (mysql_num_rows($q4) < 1) { // Očito da su aktuelna i prošla godina loše određene $q4 = myquery("select s.id, s.naziv, i.naziv, ss.semestar, ss.akademska_godina from studij as s, student_studij as ss, institucija as i where ss.student={$userid} and ss.studij=s.id and s.institucija=i.id order by akademska_godina desc, semestar desc limit 1"); if (mysql_num_rows($q4) < 1) { biguglyerror("Nikada niste bili nas student!"); return; } $proslagodina = mysql_result($q4, 0, 4); if (mysql_num_rows($q2) < 1) { biguglyerror("Nije kreirana nova akademska godina u koju se upisujete."); print "Kontaktirajte administratora."; return; } $q2 = myquery("select id, naziv from akademska_godina where id>{$proslagodina} order by id limit 1"); $zagodinu = mysql_result($q2, 0, 0); $agnaziv = mysql_result($q2, 0, 1); } $studij = mysql_result($q4, 0, 0); $studij_naziv = mysql_result($q4, 0, 1); $institucija_naziv = mysql_result($q4, 0, 2); $godina_studija = ceil(mysql_result($q4, 0, 3) / 2); // Da li je student popunio ugovor za drugi odsjek? $tekst_mijenja = ""; $q7 = myquery("select s.id, s.naziv, i.naziv from studij as s, ugovoroucenju as uou, institucija as i where uou.student={$userid} and uou.studij=s.id and s.institucija=i.id and uou.akademska_godina={$zagodinu}"); if (mysql_num_rows($q7) > 1 && $studij != mysql_result($q7, 0, 0)) { $institucija_naziv = mysql_result($q7, 0, 2); $tekst_mijenja = "predao sam zahtjev za promjenu studija na " . mysql_result($q7, 0, 1) . ". S tim u vezi, "; } // Zapis u tabeli kolizija $predmeti_kolizija = $predmeti_ects = array(); $q10 = myquery("select p.id, p.naziv, p.ects from kolizija as k, predmet as p where k.student={$userid} and k.akademska_godina={$zagodinu} and k.semestar={$semestar} and k.predmet=p.id"); if (mysql_num_rows($q10) < 1) { biguglyerror("Vi niste popunili Zahtjev za koliziju za {$agnaziv} godinu!"); print "Ako je ovo greska, kontaktirajte administratora."; return; } while ($r10 = mysql_fetch_row($q10)) { $predmeti_kolizija[$r10[0]] = $r10[1]; $predmeti_ects[$r10[0]] = $r10[2]; } if ($semestar == 1) { $s2 = 1; } else { $s2 = 0; } // Predmeti koje nije polozio $predmeti_prenos = array(); $q20 = myquery("select p.id, p.naziv, p.ects from student_predmet as sp, ponudakursa as pk, predmet as p where sp.student={$userid} and sp.predmet=pk.id and pk.predmet=p.id and pk.akademska_godina={$proslagodina} and pk.semestar MOD 2={$s2} and pk.semestar<{$godina_studija}*2+1 and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id and ko.ocjena != 5)=0"); while ($r20 = mysql_fetch_row($q20)) { if (array_key_exists($r20[0], $predmeti_kolizija)) { continue; } $predmeti_prenos[$r20[0]] = $r20[1]; $predmeti_ects[$r20[0]] = $r20[2]; } // Podaci o studentu $q30 = myquery("select ime, prezime, brindexa, spol from osoba where id={$userid}"); $ime = mysql_result($q30, 0, 0); $prezime = mysql_result($q30, 0, 1); $brindexa = mysql_result($q30, 0, 2); $spol = mysql_result($q30, 0, 3); if ($spol == "") { $spol = spol(mysql_result($q30, 0, 0)); } if ($spol == "M") { $student = "student"; $polozio = "položio"; } else { $student = "studentica"; $polozio = "položila"; } ?> <html> <head> <title>Zahtjev za koliziju</title> </head> <body> <p>Univerzitet u Sarajevu<br> Elektrotehnički fakultet Sarajevo<br> <?php echo $institucija_naziv; ?> </p> <p> </p> <p>Student: <?php echo "{$ime} {$prezime} ({$brindexa})"; ?> </p> <p> </p> <p><b>Predmet: ZAHTJEV ZA KOLIZIJU</b></p> <p> </p> <p>Ja, <?php echo "{$ime} {$prezime}"; ?> , <?php echo $student; ?> studija <?php echo $studij_naziv; ?> , <?php echo $godina_studija; ?> . godina, broj indexa <?php echo $brindexa; ?> , <?php echo $tekst_mijenja; ?> molim Vas da mi u skladu sa Zakonom o visokom obrazovanju Kantona Sarajevo, u <?php echo $tekst_semestar; ?> semestru akademske <?php echo $agnaziv; ?> godine odobrite slušanje sljedećih predmeta sa <?php echo $godina_studija + 1; ?> . godine studija u koliziji:</p> <ul> <?php foreach ($predmeti_kolizija as $id => $predmet) { print "<li>{$predmet} (" . $predmeti_ects[$id] . " ECTS)</li>\n"; } ?> </ul> <p> </p> <p>Obzirom da sa <?php echo $godina_studija; ?> . godine studija nisam <?php echo $polozio; ?> sljedeće predmete:</p> <ul> <?php foreach ($predmeti_prenos as $id => $predmet) { print "<li>{$predmet} (" . $predmeti_ects[$id] . " ECTS)</li>\n"; } ?> </ul> te da se jedan predmet prenosi, nije prekoračen maksimalan broj od 30 ECTS kredita po semestru.</p> <p> </p> <p>U nadi da ćete udovoljiti mom zahtjevu,</p> <p> </p> <table border="0"><tr><td width="100%"> </td><td align="right"><p> </p><p>_____________________________________</p></td></tr> <tr><td width="100%"> </td><td align="center"><?php echo "{$ime} {$prezime}"; ?> </td></tr></table> </body> </html> <?php return; $q5 = myquery("select uu.id, s.id, s.naziv, s.naziv_en, uu.semestar, s.tipstudija from ugovoroucenju as uu, studij as s where uu.student={$userid} and uu.akademska_godina={$zagodinu} and uu.studij=s.id order by semestar desc limit 1"); if (mysql_num_rows($q5) < 1) { niceerror("Nije kreiran ugovor o učenju za studenta."); return; } $ugovorid = mysql_result($q5, 0, 0); $studij = mysql_result($q5, 0, 1); $studijbos = mysql_result($q5, 0, 2); $studijbos = substr($studijbos, 0, strpos($studijbos, "(") - 1); $studijeng = mysql_result($q5, 0, 3); $sem2 = mysql_result($q5, 0, 4); $tipstudija = mysql_result($q5, 0, 5); $sem1 = $sem2 - 1; $godina = $sem2 / 2; // Ostali podaci o osobi $q10 = myquery("select ime, prezime, brindexa from osoba where id={$userid}"); $imeprezime = mysql_result($q10, 0, 0) . " " . mysql_result($q10, 0, 1); $brindexa = mysql_result($q10, 0, 2); // Najnoviji plan za odabrani studij $q6 = myquery("select godina_vazenja from plan_studija where studij={$studij} order by godina_vazenja desc limit 1"); if (mysql_num_rows($q6) < 1) { niceerror("Nepostojeći studij"); return; } $najnoviji_plan = mysql_result($q6, 0, 0); // Da li je ponovac? $q20 = myquery("select semestar from student_studij where student={$userid} and studij={$studij} and akademska_godina={$proslagodina} order by semestar desc limit 1"); if ($sem1 > mysql_result($q20, 0, 0)) { $ponovac = 0; } else { $ponovac = 1; } // Odredjujemo da li ima prenesenih predmeta // TODO: ovo sada ne radi za izborne predmete $q20 = myquery("select p.sifra, p.naziv, p.ects, ps.semestar from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and (ps.semestar=" . ($sem1 - 1) . " or ps.semestar=" . ($sem1 - 2) . ") and ps.obavezan=1 and ps.predmet=p.id and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0"); if (mysql_num_rows($q20) > 1) { niceerror("Nemate uslove za upis {$godina}. godine studija"); print "Sačekajte da prikupite uslov ili popunite Ugovor za prethodnu godinu studija."; return; } if (mysql_num_rows($q20) == 1) { $ima_preneseni = 1; $preneseni_sifra = mysql_result($q20, 0, 0); $preneseni_naziv = mysql_result($q20, 0, 1); $preneseni_ects = mysql_result($q20, 0, 2); $preneseni_semestar = mysql_result($q20, 0, 3); } else { $ima_preneseni = 0; } // Privremeni hack za master if ($tipstudija == 3) { $mscfile = "-msc"; } else { if ($tipstudija == 2) { $mscfile = ""; } } // Ako čovjek upisuje prvu godinu nečeka (mastera), broj indexa je netačan! if ($godina == 1) { $brindexa = ""; } // ----- Pravljenje PDF dokumenta $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator("Zamger"); $pdf->SetTitle('Domestic Learning Agreement / Ugovor o ucenju'); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(0, 0, 0); //set auto page breaks $pdf->SetAutoPageBreak(false); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO*2.083333); $pdf->setJPEGQuality(100); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('freesans', 'B', 9); $pdf->SetHeaderData("", 0, "", ""); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); // add a page $pdf->AddPage(); // $pdf->Image("images/content/150dpi/ETF-Domestic-contract-PGS-ALL-0.png",210,297,0,0,'','','',true,150); $pdf->Image("images/content/150dpi/domestic-contract{$mscfile}-0.png", 0, 0, 210, 0, '', '', '', true, 150); $pdf->SetXY(175, 34); $pdf->Cell(23, 0, $agnaziv, 0, 0, 'C'); $pdf->SetXY(175, 42); $pdf->Cell(23, 0, $godina . ".", 0, 0, 'C'); $pdf->SetXY(175, 50); $pdf->Cell(23, 0, $sem1 . ". & " . $sem2, 0, 0, 'C'); $pdf->SetXY(70, 48); $pdf->Cell(100, 0, $studijeng, 0, 0); $pdf->SetXY(70, 52); $pdf->Cell(100, 0, $studijbos, 0, 0); $pdf->SetXY(70, 62); $pdf->Cell(100, 0, $imeprezime); $pdf->SetXY(70, 69); $pdf->Cell(100, 0, $brindexa); // PRVI SEMESTAR $pdf->AddPage(); $pdf->Image("images/content/150dpi/domestic-contract{$mscfile}-1.png", 0, 0, 210); $pdf->SetXY(175, 34); $pdf->Cell(23, 0, $agnaziv, 0, 0, 'C'); $pdf->SetXY(175, 42); $pdf->Cell(23, 0, $godina . ".", 0, 0, 'C'); $pdf->SetXY(175, 50); $pdf->Cell(23, 0, $sem1 . ".", 0, 0, 'C'); $pdf->SetXY(70, 48); $pdf->Cell(100, 0, $studijeng, 0, 0); $pdf->SetXY(70, 52); $pdf->Cell(100, 0, $studijbos, 0, 0); $pdf->SetXY(70, 62); $pdf->Cell(100, 0, $imeprezime); $pdf->SetXY(70, 69); $pdf->Cell(100, 0, $brindexa); // Spisak obaveznih predmeta na neparnom semestru // Ako je ponovac, ne prikazujemo predmete koje je polozio if ($ponovac == 1) { $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem1} and ps.obavezan=1 and ps.predmet=p.id and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0"); } else { // Ako nije, trebamo prikazati one koje je položio u koliziji $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem1} and ps.obavezan=1 and ps.predmet=p.id"); } $ykoord = 95; $ects = 0; while ($r100 = mysql_fetch_row($q100)) { $pdf->SetXY(13, $ykoord); $pdf->Cell(100, 0, $r100[0]); $pdf->SetXY(50, $ykoord); $pdf->Cell(100, 0, $r100[1]); $e = "{$r100['2']}"; if (!strchr($e, ".")) { $e .= ".0"; } $pdf->SetXY(170, $ykoord); $pdf->Cell(100, 0, $e); $ykoord += 4; $ects += $r100[2]; } // Da li je prenesen predmet na neparnom semestru? if ($ima_preneseni && $preneseni_semestar % 2 == 1) { $pdf->SetXY(13, $ykoord); $pdf->Cell(100, 0, $preneseni_sifra); $pdf->SetXY(50, $ykoord); $pdf->Cell(100, 0, $preneseni_naziv); $e = "{$preneseni_ects}"; if (!strchr($e, ".")) { $e .= ".0"; } $pdf->SetXY(170, $ykoord); $pdf->Cell(100, 0, $e); $ykoord += 4; $ects += $preneseni_ects; } // Spisak izbornih predmeta if ($ponovac == 1) { $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem1} and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0"); } else { $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem1}"); } $ykoord = 123; while ($r110 = mysql_fetch_row($q110)) { $pdf->SetXY(13, $ykoord); $pdf->Cell(100, 0, $r110[0]); $pdf->SetXY(50, $ykoord); $pdf->Cell(100, 0, $r110[1]); $e = "{$r110['2']}"; if (!strchr($e, ".")) { $e .= ".0"; } $pdf->SetXY(170, $ykoord); $pdf->Cell(100, 0, $e); $ykoord += 4; $ects += $r110[2]; } // Suma ects if (!strchr($ects, ".")) { $ects .= ".0"; } $pdf->SetXY(170, 135); $pdf->Cell(100, 0, $ects); // DRUGI SEMESTAR $pdf->AddPage(); $pdf->Image("images/content/150dpi/domestic-contract{$mscfile}-2.png", 0, 0, 210); $pdf->SetXY(175, 34); $pdf->Cell(23, 0, $agnaziv, 0, 0, 'C'); $pdf->SetXY(175, 42); $pdf->Cell(23, 0, $godina . ".", 0, 0, 'C'); $pdf->SetXY(175, 50); $pdf->Cell(23, 0, $sem2 . ".", 0, 0, 'C'); $pdf->SetXY(70, 48); $pdf->Cell(100, 0, $studijeng, 0, 0); $pdf->SetXY(70, 52); $pdf->Cell(100, 0, $studijbos, 0, 0); $pdf->SetXY(70, 62); $pdf->Cell(100, 0, $imeprezime); $pdf->SetXY(70, 69); $pdf->Cell(100, 0, $brindexa); // Spisak obaveznih predmeta na parnom semestru if ($ponovac == 1) { $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem2} and ps.obavezan=1 and ps.predmet=p.id and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0"); } else { $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem2} and ps.obavezan=1 and ps.predmet=p.id"); } $ykoord = 95; $ects = 0; while ($r100 = mysql_fetch_row($q100)) { $pdf->SetXY(13, $ykoord); $pdf->Cell(100, 0, $r100[0]); $pdf->SetXY(50, $ykoord); $pdf->Cell(100, 0, $r100[1]); $e = "{$r100['2']}"; if (!strchr($e, ".")) { $e .= ".0"; } $pdf->SetXY(170, $ykoord); $pdf->Cell(100, 0, $e); $ykoord += 4; $ects += $r100[2]; } // Da li je prenesen predmet na parnom semestru? if ($ima_preneseni && $preneseni_semestar % 2 == 0) { $pdf->SetXY(13, $ykoord); $pdf->Cell(100, 0, $preneseni_sifra); $pdf->SetXY(50, $ykoord); $pdf->Cell(100, 0, $preneseni_naziv); $e = "{$preneseni_ects}"; if (!strchr($e, ".")) { $e .= ".0"; } $pdf->SetXY(170, $ykoord); $pdf->Cell(100, 0, $e); $ykoord += 4; $ects += $preneseni_ects; } // Spisak izbornih predmeta if ($ponovac == 1) { $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem2} and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0"); } else { $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem2}"); } $ykoord = 123; while ($r110 = mysql_fetch_row($q110)) { $pdf->SetXY(13, $ykoord); $pdf->Cell(100, 0, $r110[0]); $pdf->SetXY(50, $ykoord); $pdf->Cell(100, 0, $r110[1]); $e = "{$r110['2']}"; if (!strchr($e, ".")) { $e .= ".0"; } $pdf->SetXY(170, $ykoord); $pdf->Cell(100, 0, $e); $ykoord += 4; $ects += $r110[2]; } // Suma ects if (!strchr($ects, ".")) { $ects .= ".0"; } $pdf->SetXY(170, 135); $pdf->Cell(100, 0, $ects); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('ugovor_o_ucenju.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ }
function createPdfFromImage($arrImagename, $strFilename) { $this->load->library('tcpdf/TCPDF'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // ------------------------------------------------------------------- $pdf->AddPage(); $pdf->setJPEGQuality(75); $imgdata = base64_decode('iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='); $pdf->Image('@' . $imgdata); $intY = 25; foreach ($arrImagename as $intkey => $oneImage) { if ($intkey % 2 == 0 && $intkey != 0) { $intY = 25; $pdf->AddPage(); } $pdf->Image($oneImage, 10, $intY, 180, 103, 'png', '', 'C', true, 150, '', false, false, 1, false, false, false); $intY += 125; } $pdf->Output($strFilename . '.pdf', 'I'); }
function showPdf($idReg = "") { global $db; // Oficina $sesIdOficina = $_SESSION[sesIdOficina]; $oficina = getValueTable("oficina", "OFICINA", "id_oficina", $sesIdOficina); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', false, 'ISO-8859-1', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 009'); $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.' 009', PDF_HEADER_STRING); // 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); // $pdf->SetFooterMargin(3); $pdf->setPageOrientation('P', '', 1); //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 //$pdf->setLanguageArray($l); // set some language dependent data: $lg = array(); $lg['a_meta_charset'] = 'ISO-8859-1'; $lg['a_meta_dir'] = 'ltr'; $lg['a_meta_language'] = 'en'; $lg['w_page'] = 'page'; //set some language-dependent strings $pdf->setLanguageArray($lg); // ------------------------------- // CONSULTA DE DATOS // ------------------------------- $sql = "select * from INVENTARIO where id_inventario='{$idReg}'"; $db->query($sql); while ($db->next_record()) { $entSal = $db->f('ent_sal'); $eir = $db->f(eir); //$idCliente = $db->f('id_cliente'); //$cliente = getValueTable("cliente","CLIENTE","id_cliente",$idCliente); $cliente = $db->f('consig'); $idConte = $db->f('id_contenedor'); $conte = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte); if (preg_match("/(\\w{4})(\\d{7})/", $conte, $parts)) { $conteL = $parts[1]; $conteN = $parts[2]; } $idEq = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte); $equipo = getValueTable("equipo", "EQUIPO", "id_equipo", $idEq); $bkg = $db->f('bkg'); $clase = $db->f('clase'); $clase = "CLASE: {$clase} "; $damage = $db->f('damage'); $sello = $db->f('sello'); $nota = $db->f('nota'); //$idTrans = $db->f('id_transporte'); //$transp = getValueTable("transporte","TRANSPORTE","id_transporte",$idTrans); $transp = $db->f('transportista'); $conteP1 = substr($conte, 0, 4); $conteP2 = substr($conte, 4, 10); if (preg_match("/(\\d+)(\\d)\$/", $conteP2, $parts)) { $conteP2 = $parts[1] . "-" . $parts[2]; } $idNav = $db->f('id_naviera'); $naviera = getValueTable("naviera", "NAVIERA", "id_naviera", $idNav); $placas = $db->f('placas'); // $idOperador = $db->f('id_operador'); //$operador = getValueTable("operador","OPERADOR","id_operador",$idOperador); $operador = $db->f('operador'); $capFec = $db->f('cap_fec'); if ($entSal == "E") { $entSalTx = "INVENTARIO"; } if ($entSal == "S") { $entSalTx = "SALIDA"; } $tipoMani = $db->f('tipo_mani'); $noRecibo = $db->f('recibo'); if ($tipoMani == "D") { $tipoManiTx = "MANIOBRA DE DESCARGA"; } if ($tipoMani == "C") { $tipoManiTx = "MANIOBRA DE CARGA"; } $maniCosto = $db->f('mani_costo'); $montoLetra = traducirCifra($maniCosto); $capIdUsr = $db->f('cap_id_usr'); $capFec = $db->f('cap_fec'); $capUsr = getValueTable("usuario", "USUARIO", "id_usuario", $capIdUsr); } // ------------------------------ // DAÑOS // ------------------------------ $sql = "select * from REL_NOME "; $sql .= "where id_inventario='{$idReg}' "; $dano = ""; $db->query($sql); while ($db->next_record()) { $idRelNome = $db->f(id_rel_nome); $idNome = $db->f(id_nome); $idUbica = $db->f(id_ubicacion); $idDime = $db->f(id_dimension); $nome = getValueTable("nombre", "NOMENCLATURA", "id_nome", $idNome); $nomeCode = getValueTable("codigo", "NOMENCLATURA", "id_nome", $idNome); $ubica = getValueTable("ubicacion", "UBICACION", "id_ubicacion", $idUbica); $dimen = getValueTable("dimension", "DIMENSION", "id_dimension", $idDime); $dano .= "{$nome} ({$nomeCode}) : {$ubica} : {$dimen}\n"; } $dano = nl2br($dano); // --------------------------------------------------------- // DATOS DEL RECIBO // --------------------------------------------------------- if ($noRecibo > 0) { $datoRecibo = "\n <table cellspacing=\"0\" cellpadding=\"3\" border=\"1\" align=\"center\"> \n <tr>\n <td colspan=\"4\" valign=\"middle\"><b>DEPOSITO DE CONTENEDORES</b></td>\n <td>\n <table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" align=\"center\"> \n <tr>\n <td bgcolor=\"black\"><b><font color=\"white\">FOLIO</font></b></td>\n </tr>\n <tr>\n <td><font color=\"red\"><b>No. {$noRecibo}</b></font></td>\n </tr>\n </table>\n </td>\n </tr> \n <tr>\n <td><b>FECHA</b></td>\n <td><b>No.R.I.E.</b></td> \n <td></td>\n <td><b>CONTENEDOR</b></td>\n <td><b>TIPO</b></td>\n </tr>\n <tr>\n <td>{$capFec}</td> \n <td>{$idReg}</td>\n <td></td>\n <td>{$conteL}{$conteN}</td>\n <td>{$equipo}</td>\n </tr> \n <tr>\n <td><b>CONCEPTO</b></td> \n <td><b>TRANSPORTISTA</b></td> \n <td><b>OPERADOR</b></td>\n <td colspan=\"2\"><b>OBSERVACIONES</b></td> \n </tr> \n <tr> \n <td>{$tipoManiTx}</td> \n <td>{$transp}</td>\n <td>{$operador}</td> \n <td colspan=\"2\">{$nota}</td> \n </tr>\n </table>\n <table cellspacing=\"0\" cellpadding=\"3\" border=\"1\" align=\"center\">\n <tr>\n <td ><b>FIRMA OPERADOR</b></td>\n <td ><b>FIRMA DEL DEPOSITO</b></td>\n <td>\n <table cellspacing=\"0\" cellpadding=\"3\" border=\"1\" align=\"center\">\n <tr>\n <td align=\"right\"><b>MANIOBRA \$</b></td>\n <td align=\"left\">{$maniCosto}</td>\n </tr>\n <tr>\n <td align=\"right\"><b>SUBTOTAL \$</b></td>\n <td align=\"left\">{$maniCosto}</td>\n </tr>\n <tr>\n <td align=\"right\"><b>IVA \$</b></td>\n <td align=\"left\">{$maniIva}</td>\n </tr>\n <tr>\n <td align=\"right\"><b>TOTAL \$</b></td>\n <td align=\"left\">{$maniCosto}</td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td colspan=\"3\" align=\"left\">RECIBIMOS DE <u>{$operador}</u> LA CANTIDAD DE {$montoLetra} PESOS M.N. 00/100 </td>\n </tr>\n </table> \n "; } // ------------------------------------------------------------------- $pdf->AddPage(); // Logo $pdf->setJPEGQuality(100); $pdf->Image('../images/logo_color.jpg', 13, 4, 25, 25, '', '', '', false); //$pdf->Image('../images/nome.jpg', 15, 140, 185, 96,'','','',false); // set cell padding //$pdf->setCellPaddings(1, 1, 1, 1); // set cell margins //$pdf->setCellMargins(1, 1, 1, 1); // Encabezado $pdf->SetFillColor(197, 197, 197); if ($sesIdOficina == 1) { $txt = "ALMARTCON, S.A. DE C.V.\n\"El Trébol\""; $pdf->SetFont('helvetica', '', 14); $pdf->MultiCell(65, 4, $txt, 0, 'L', 0, 0, 40, 10, true); $txt = "Direccion, Guatemala \nTels.: 505-2350-0976 Cel. 505-8635-0708"; $pdf->SetFont('helvetica', '', 7); $pdf->MultiCell(60, 4, $txt, 0, 'C', 0, 0, 105, 10, true); } /* elseif( $sesIdOficina==3 ){ $txt = "TRANSPORTES MALEJA, S.A. DE C.V.\n\"El Pino\""; $pdf->SetFont('helvetica', '', 14); $pdf->MultiCell(65, 4,$txt, 0, 'L',0, 0, 40, 10,true); $txt="Carretera Querétaro San Luis Potosí Km.28\nCol.Buenavista Santa Rosa Jauregui\nQueretaro, QRO."; $pdf->SetFont('helvetica', '', 7); $pdf->MultiCell(60, 4,$txt, 0, 'C',0, 0, 105, 10,true); } */ $pdf->SetFont('helvetica', '', 12); $tbl = <<<EOD <table cellspacing="0" cellpadding="3" border="1" align="center"> <tr bgcolor="#cacaca"> <th>FOLIO</th> </tr> <tr> \t \t<td><font color="red">{$entSal} {$eir}</font></td> </tr> </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $txt = "RECIBO DE INTERCAMBIO DE EQUIPO (R.I.E)"; $pdf->SetFont('helvetica', 'B', 12); $pdf->MultiCell(100, 4, $txt, 0, 'C', 0, 0, 60, 37, true); $pdf->SetFont('helvetica', '', 8); $tbl = <<<EOD <br><br><br> <table cellspacing="0" cellpadding="3" border="1" align="center"> <tr> <th><b>CLIENTE</b></th> <th><b>MARCA</b></th> <th><b>NUMERO</b></th> <th><b>CARACTERISTICAS FISICAS</b></th> </tr> <tr> \t \t<td>{$cliente}</td> \t<td>{$conteL}</td> \t<td>{$conteN}</td> \t<td>{$equipo} / {$damage} </td> \t </tr> <tr bgcolor="#cacaca"> \t<th colspan="4"><b>{$entSalTx}</b></th> </tr> <tr> \t<td><b>ENTREGADO POR :</b></td> \t<td><b>FECHA Y HORA</b></td> <td><b>BOOKING</b></td> \t<td><b>ESTADO FISICO</b></td> \t </tr> <tr> \t<td>{$naviera}</td> \t<td>{$capFec}</td> <td>{$bkg}</td> \t<td>{$clase}</td> \t </tr> <tr> \t<td><b>TRANSPORTISTA</b></td> <td><b>OPERADOR</b></td> <td><b>PLACAS</b></td> \t<td><b>SELLO</b></td> \t \t </tr>\t <tr> \t<td>{$transp}</td> <td>{$operador}</td> <td>{$placas}</td> <td>{$sello}</td> </tr> <tr> \t<td colspan="2"><b>OBSERVACIONES</b></td> \t <td colspan="2"><b>DANOS</b></td> </tr> <tr> <td colspan="2">{$nota}</td> \t<td colspan="2">{$dano}</td> </tr> <tr> <td colspan="4"><i>Capturo: {$capUsr}<br>Fecha captura: {$capFec} </i></td> </tr> </table> <br><br><br> {$datoRecibo} EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $noRecibo > 0 ? $corY = 180 : ($corY = 105); $txt = "POR TRANSPORTISTA\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40, 10, $txt, 1, 'C', 0, 0, 15, $corY, true); $txt = "POR DEPOSITO\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(30, 10, $txt, 1, 'C', 0, 0, 55, $corY, true); $txt = "AUTO. DE REPARACION\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40, 10, $txt, 1, 'C', 0, 0, 85, $corY, true); $txt = "POR TRANSPORTISTA\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40, 10, $txt, 1, 'C', 0, 0, 125, $corY, true); $txt = "POR DEPOSITO\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(35, 10, $txt, 1, 'C', 0, 0, 165, $corY, true); //Close and output PDF document $pdf->Output('example_eir.pdf', 'I'); }
// 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 $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'BI', 50); // add a page $pdf->AddPage(); //Start Graphic Transformation $pdf->StartTransform(); // set clipping mask $pdf->StarPolygon(50, 70, 30, 10, 3, 0, 1, 'CNZ'); // draw jpeg image to be clipped $pdf->Image('../images/image_demo.jpg', 20, 40, 60, 60, '', 'http://www.tcpdf.org', '', true, 72); //Stop Graphic Transformation $pdf->StopTransform(); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_034.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
function izvjestaj_prijemni_brzi_unos() { require_once 'lib/tcpdf/tcpdf.php'; $termin = intval($_REQUEST['termin']); $osoba = intval($_REQUEST['osoba']); $q10 = myquery("select ime, prezime, imeoca, jmbg from osoba where id={$osoba}"); if (mysql_num_rows($q10) < 1) { biguglyerror("Nepostojeća osoba"); zamgerlog("nepostojeca osoba {$osoba}", 3); return; } $ime = mysql_result($q10, 0, 0); $prezime = mysql_result($q10, 0, 1); $imeoca = mysql_result($q10, 0, 2); $jmbg = mysql_result($q10, 0, 3); $q20 = myquery("select sifra, jezik from prijemni_obrazac where osoba={$osoba} and prijemni_termin={$termin}"); if (mysql_num_rows($q20) < 1) { biguglyerror("Ne postoji obrazac za ovu osobu"); zamgerlog("za osobu u{$osoba} ne postoji obrazac na terminu {$termin}", 3); return; } $sifra = mysql_result($q20, 0, 0); $jezik = mysql_result($q20, 0, 1); $datum = date("d. m. Y."); $vrijeme = date("h:i"); // ----- Pravljenje PDF dokumenta $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator("Zamger"); $pdf->SetTitle('Sifra kandidata i pregled vaznijih datuma'); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(0, 0, 0); //set auto page breaks $pdf->SetAutoPageBreak(false); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO*2.083333); $pdf->setJPEGQuality(100); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('freesans', '', 48); $pdf->SetHeaderData("", 0, "", ""); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); // add a page $pdf->AddPage(); // $pdf->Image("images/content/150dpi/ETF-Domestic-contract-PGS-ALL-0.png",210,297,0,0,'','','',true,150); if ($jezik == "en") { $pdf->Image("images/content/150dpi/obrazac_sa_sifrom_en.png", 0, 0, 210, 0, '', '', '', true, 150); $en_offset = 7; } else { $pdf->Image("images/content/150dpi/obrazac_sa_sifrom.png", 0, 0, 210, 0, '', '', '', true, 150); $en_offset = 0; } $pdf->SetXY(130, 15); $pdf->Cell(23, 0, $sifra, 0, 0, 'C'); $pdf->SetFont('freesans', '', 16); $pdf->SetXY(80, 62 + $en_offset); $pdf->Cell(23, 0, "{$ime} ({$imeoca}) {$prezime}"); $pdf->SetXY(80, 73 + $en_offset); $pdf->Cell(23, 0, $jmbg); $pdf->SetFont('freesans', '', 14); $pdf->SetXY(40, 113 + $en_offset); $pdf->Cell(23, 0, $datum); $pdf->SetXY(130, 113 + $en_offset); $pdf->Cell(23, 0, $vrijeme); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('obrazac_sa_sifrom.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ }
public function testPdfOutput() { $this->markTestIncomplete('Travis failure needs further investigation. '); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 042'); $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 . ' 042', PDF_HEADER_STRING); // 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) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- // set JPEG quality //$pdf->setJPEGQuality(75); $pdf->SetFont('helvetica', '', 18); // add a page $pdf->AddPage(); // create background text $background_text = str_repeat('TCPDF test PNG Alpha Channel ', 50); $pdf->MultiCell(0, 5, $background_text, 0, 'J', 0, 2, '', '', true, 0, false); // --- Method (A) ------------------------------------------ // the Image() method recognizes the alpha channel embedded on the image: $pdf->SetAlpha(0.71); $pdf->Image('tests/images/image_with_alpha.png', 50, 50, 100, '', '', 'http://www.tcpdf.org', '', false, 300); $pdf->SetAlpha(1); // --- Method (B) ------------------------------------------ // provide image + separate 8-bit mask // first embed mask image (w, h, x and y will be ignored, the image will be scaled to the target image's size) $mask = $pdf->Image('tests/images/alpha.png', 50, 140, 100, '', '', '', '', false, 300, '', true); // embed image, masked with previously embedded mask $pdf->Image('tests/images/img.png', 50, 140, 100, '', '', 'http://www.tcpdf.org', '', false, 300, '', false, $mask); $this->comparePdfs($pdf); }
function processing($contextData, $options) { $prodId = $contextData[0]['id']; $prodName = $contextData[0]['name']; $unitPrice = $contextData[0]['unitprice']; $pFile = $contextData[0]['photofile']; $timestamp = new DateTime(); $tsString = $timestamp->format("Y-m-d H:i:s"); $fileName = "{$prodId}.pdf"; require_once './tcpdf/tcpdf.php'; $pdf = new TCPDF("P", "mm", "A4", true, "UTF-8"); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetMargins(0, 0, 0, 0); $pdf->AddPage(); $pdf->setTextColor(100, 100, 100); $pdf->SetFont('', '', 14); $pdf->Text(40, 40, "Product ID: {$prodId}"); $pdf->Text(40, 50, "Product Name: {$prodName}"); $pdf->Text(40, 60, "Unit Price: {$unitPrice}"); $pdf->Text(40, 70, "Today: {$tsString}"); $pdf->Image("../Sample_products/images/{$pFile}", 40, 80, 100); header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=\"{$fileName}\""); header('X-Frame-Options: SAMEORIGIN'); $pdf->Output(); }
/** * Add an image to the pdf. * * The image is placed at the specified x and y coordinates with the * given width and height. * * @param string $img_url the path to the image * @param string $img_type the type (e.g. extension) of the image * @param float $x x position * @param float $y y position * @param int $w width (in pixels) * @param int $h height (in pixels) */ function image($img_url, $img_type, $x, $y, $w, $h) { dompdf_debug("trace", "({$img_url}, {$img_type}, {$x}, {$y}, {$w}, {$h})"); if ($img_type == 'gif') { $img_url = $this->_convert_gif_to_png($img_url); $img_type = 'png'; } $this->_pdf->Image($img_url, $x, $y, $w, $h, $img_type); }
public function prepareDownloadImagePdf($filename, $newfilename, $firstname, $lastname, $title, $description, $code, $date_end) { // calculate date $currentDate = new DateTime(); $currentDate->modify('+ ' . $date_end . ' month'); $date_end = $currentDate->format('Y-m-d'); $this->load->model('tool/image'); require_once DIR_SYSTEM . 'library/tcpdf/tcpdf.php'; $pdf = new TCPDF(); // disable auto-page-break $pdf->SetAutoPageBreak(false, 0); // set image 1 $pdf->AddPage(); $pdf->Image(DIR_IMAGE . $filename, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); $pdf->setPageMark(); /*if(stripos('.pdf',$newfilename)===false) { $t = explode('.',$newfilename); array_pop($t); $newfilename = implode('.',$t).'.pdf'; }*/ $pdf->SetFont('times', '', 13); $pdf->SetTextColor(50, 50, 50); for ($i = 0; $i <= 16; $i++) { $pdf->Ln(10); } $pdf->setCellPaddings(90); $pdf->Ln(10); $pdf->Write(0, $firstname . ' ' . $lastname); $pdf->Ln(10); $pdf->Ln(10); $pdf->Write(0, $title); $pdf->Ln(10); $pdf->SetFont('times', '', 11); $pdf->Write(0, $description); $pdf->setCellPaddings(70); $pdf->Ln(10); $pdf->Ln(10); $pdf->Ln(10); $pdf->Ln(10); $pdf->Ln(10); $pdf->SetFont('times', '', 7); $pdf->Write(0, 'Beauty Center Billstedt'); $pdf->Ln(4); $pdf->SetFont('times', 'B', 9); $pdf->Write(0, '#' . $code); $pdf->Ln(4); $pdf->SetFont('times', '', 9); $pdf->Write(0, 'Gültig bis:: ' . $date_end); $pdf->Output(DIR_IMAGE . $newfilename, 'F'); }
/** * Add an image to the pdf. * * The image is placed at the specified x and y coordinates with the * given width and height. * * @param string $img_url the path to the image * @param string $img_type the type (e.g. extension) of the image * @param float $x x position * @param float $y y position * @param int $w width (in pixels) * @param int $h height (in pixels) */ function image($img, $x, $y, $w, $h, $resolution = "normal") { //*** if ($img_type == 'gif') { // $img_url = $this->_convert_gif_to_png($img_url); // $img_type = 'png'; // } $path_parts = pathinfo($img); $img_url = $img; $img_type = strtolower($path_parts['extension']); if ($img_type == 'gif') { $img_url = $this->_convert_gif_to_png($img_url); $img_type = 'png'; } $this->_pdf->Image($img_url, $x, $y, $w, $h, $img_type); }
public function testPdfOutput() { // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 034'); $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 . ' 034', PDF_HEADER_STRING); // 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) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'B', 20); // add a page $pdf->AddPage(); $pdf->Write(0, 'Image Clipping using geometric functions', '', 0, 'C', 1, 0, false, false, 0); //Start Graphic Transformation $pdf->StartTransform(); // set clipping mask $pdf->StarPolygon(105, 100, 30, 10, 3, 0, 1, 'CNZ'); // draw jpeg image to be clipped $pdf->Image('tests/images/image_demo.jpg', 75, 70, 60, 60, '', 'http://www.tcpdf.org', '', true, 72); //Stop Graphic Transformation $pdf->StopTransform(); $this->comparePdfs($pdf); }
public function render(\TCPDF $pdf, $width = null) { $image = $this->_obj->getContent(); $imgSize = getimagesize(Core::$basePath . $image); $height = $pdf->pixelsToUnits($imgSize[1]); $width = $pdf->pixelsToUnits($imgSize[0]); $pdf->setJPEGQuality(75); if ($this->_obj->getParameter('pos_x') || $this->_obj->getParameter('pos_y')) { $currentY = $pdf->getY(); $currentAPB = $pdf->getAutoPageBreak(); $currentMB = $pdf->getMargins(); $currentMB = $currentMB['bottom']; $pdf->setAutoPageBreak(false, 0); $pdf->write(''); } $pdf->Image(Core::$basePath . $image, $this->_obj->getParameter('pos_x') ? $pdf->pixelsToUnits($this->_obj->getParameter('pos_x')) : null, $this->_obj->getParameter('pos_y') ? $pdf->pixelsToUnits($this->_obj->getParameter('pos_y')) : null, $width * $this->_obj->getParameter('ratio'), $height * $this->_obj->getParameter('ratio'), null, $this->_obj->getParameter('link'), 'N'); if (isset($currentY)) { $pdf->setY($currentY); $pdf->setAutoPageBreak($currentAPB, $currentMB); } }
public function getAttatchment() { $title = $this->input->get('title'); $attatch = $this->input->get('attatchment'); $this->form_validation->set_rules('reportTitle', 'Report Title', 'required'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); tcpdf(); // create new PDF document $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); //set title of report $obj_pdf->SetAuthor($this->session->userdata['username']); $obj_pdf->SetTitle($title); $obj_pdf->SetCreator(PDF_CREATOR); $obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, PDF_HEADER_STRING); $obj_pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $obj_pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $obj_pdf->SetDefaultMonospacedFont('helvetica'); $obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $obj_pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $obj_pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $obj_pdf->SetFont('helvetica', '', 9); $obj_pdf->setFontSubsetting(false); $obj_pdf->AddPage(); $obj_pdf->Image($attatch, 15, 140, 75, 113, 'JPG', 'http://www.tcpdf.org', '', true, 150, '', false, false, 1, false, false, false); $path = 'C:/xampp/htdocs/QADash/public_html/reports'; // Supply a filename including the .pdf extension $filename = $this->{$title}; // Create the full path $full_path = $path . '/' . $filename; // Output PDF $obj_pdf->Output($full_path, 'F'); //save report details in database $details = $this->saveReport($this->session->userdata['uid'], $filename, $path . '/' . $filename); $this->report_m->saveReport($details); //redirect to view the generated pdf file $this->data['report'] = $filename; $this->data['subview'] = 'manager/user/report/singleReport_view'; $this->load->view("manager/_layout_main", $this->data); }
function createsignpage($text, $signatureimagepath, $outputpath) { // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // 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 font $pdf->SetFont('helvetica', '', 12); // add a page $pdf->AddPage(); // print a line of text $pdf->writeHTML($text, true, 0, true, 0); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // *** set signature appearance *** // create content for signature (image and/rm or text) $pdf->Image($signatureimagepath, 150, '', 30, '', 'JPG'); $pdf->Output($outputpath, 'F'); if (file_exists($outputpath)) { return 1; } else { return 0; } }
$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); } // --------------------------------------------------------- // add a page $pdf->AddPage(); $pdf->SetFont('times', 'BU', 14); $image_file = K_PATH_IMAGES . 'logo.jpg'; $pdf->Image($image_file, 0, 15, 0, 0, 'JPG', '', 'M', false, 150, 'C', false, false, 1, false, false, false); $pdf->Ln(6); $pdf->writeHTML('Jamnalal Bajaj Institute of Management Studies Online Application Form 2015-2017', true, false, false, false, 'C'); $pdf->Ln(10); $pdf->SetFont('helvetica', '', 8); // ----------------------------------------------------------------------------- // NON-BREAKING ROWS (nobr="true") $tbl = <<<EOD <style> body { padding: 40px; } table { } table th {
$pdf->SetAutoPageBreak(false); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setFontSubsetting(true); $pdf->SetFont('', 'B', 10, '', true); $obj = new Employee(); $company = $obj->get_company(); $pdf->SetTitle("{$company->name} - P9A"); $year = (int) $_GET['y']; $employees = $obj->get_employees(); foreach ($employees as $emp) { $id = $emp->id; $basic = $emp->basic_pay; $pdf->AddPage(); $year = (int) $_GET['y']; $pdf->Image("../assets/img/kra2.png", 100); $pdf->Ln(26); $pdf->Cell(10, 5, "P9A"); $pdf->Cell(150, 5, "TAX DEDUCTION CARD YEAR {$year}", 0, 1, "R"); $pdf->SetFont('', '', 10); $pdf->Cell(170, 5, 'Employer\'s Name: ' . $company->name); $pdf->Cell(50, 5, 'Employer\'s PIN:'); for ($i = 0; $i < 11; ++$i) { $pdf->Cell(5, 5, $company->kra_pin[$i], 1, 0, "C"); } $pdf->Ln(5); $pdf->Cell(170, 5, 'Employee\'s Main Name: ' . $emp->lname); $pdf->Ln(5); $pdf->Cell(170, 5, "Employee's Other Names: {$emp->fname} {$emp->lname}"); $pdf->Cell(50, 5, 'Employee\'s PIN:'); for ($i = 0; $i < strlen($emp->pin); ++$i) {
$pdf->SetFont('helvetica', '', 12); // add a page // set cell padding $pdf->setCellPaddings(1, 1, 1, 1); // set cell margins $pdf->setCellMargins(0, 1, 0, 1); // set font color $pdf->SetTextColor(50, 50, 50); $pdf->SetFillColor(238, 238, 238); $pdf->AddPage(); // Transparancy Image Stamp // if(!empty($dx_invoice_stamp_img)){ // $pdf->Image($dx_invoice_stamp_img, 18, 15, 16, '', '', 'http://Dxinvoice.com', '', false, 300); // } // Transparancy Image Stamp if (!empty($dx_invoice_stamp_img)) { $pdf->Image($dx_invoice_stamp_img, $dx_stamp_position, 130, 30, '', '', '', '', false, 300); } //if(!empty($dx_invoice_signature_img)) //$pdf->Image($dx_invoice_signature_img, 174, 241, 20, 10, '', 'http://Dxinvoice.com', '', false, 300); // output the HTML content $pdf->writeHTML($html, true, 0, true, 0); // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- //Get pdf name //$pdf_name = isset( $pdf_args['pdf_name'] ) && !empty( $pdf_args['pdf_name'] ) ? $pdf_args['pdf_name'] : 'edd-voucher-' . date('d-m-Y'); //Close and output PDF document //Second Parameter I that means display direct and D that means ask download or open this file $pdf->Output('pdf-generater-' . date('Y-m-d') . '.pdf', $pdf_view_type); exit;
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // ------------------------------------------------------------------- // add a page $pdf->AddPage(); // set JPEG quality $pdf->setJPEGQuality(75); // Image method signature: // Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Example of Image from data stream ('PHP rules') $imgdata = base64_decode('iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='); // The '@' character is used to indicate that follows an image data stream and not an image file name $pdf->Image('@' . $imgdata); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Image example with resizing $pdf->Image('images/image_demo.jpg', 15, 140, 75, 113, 'JPG', 'http://www.tcpdf.org', '', true, 150, '', false, false, 1, false, false, false); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // test fitbox with all alignment combinations $horizontal_alignments = array('L', 'C', 'R'); $vertical_alignments = array('T', 'M', 'B'); $x = 15; $y = 35; $w = 30; $h = 30; // test all combinations of alignments for ($i = 0; $i < 3; ++$i) { $fitbox = $horizontal_alignments[$i] . ' '; $x = 15;
// 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 JPEG quality //$pdf->setJPEGQuality(75); $pdf->SetFont('helvetica', '', 18); // add a page $pdf->AddPage(); // create background text $background_text = str_repeat('TCPDF test PNG Alpha Channel ', 50); $pdf->MultiCell(0, 5, $background_text, 0, 'J', 0, 2, '', '', true, 0, false); // --- Method (A) ------------------------------------------ // the Image() method recognizes the alpha channel embedded on the image: $pdf->Image('images/image_with_alpha.png', 50, 50, 100, '', '', 'http://www.tcpdf.org', '', false, 300); // --- Method (B) ------------------------------------------ // provide image + separate 8-bit mask // first embed mask image (w, h, x and y will be ignored, the image will be scaled to the target image's size) $mask = $pdf->Image('images/alpha.png', 50, 140, 100, '', '', '', '', false, 300, '', true); // embed image, masked with previously embedded mask $pdf->Image('images/img.png', 50, 140, 100, '', '', 'http://www.tcpdf.org', '', false, 300, '', false, $mask); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_042.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
private function generate_pdf_layers($variation_id, $layers_array, $output_file) { global $wpc_options_settings; $product_id = WPD_Product::get_parent($variation_id); $wpc_metas = get_post_meta($product_id, 'wpc-metas', true); $product_metas = WPD_Admin::get_proper_value($wpc_metas, $variation_id, array()); $variation_output_settings = WPD_Admin::get_proper_value($product_metas, "output-settings", array()); $global_output_settings = $wpc_options_settings['wpc-output-options']; $pdf_format = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-format", "A0"); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-format", "A0"); $pdf_orientation = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-orientation", "P"); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-orientation", "P"); $pdf_margin_lr = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-margin-lr", 20); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-margin-lr", 20); $pdf_margin_tb = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-margin-tb", 20); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-margin-tb", 20); /*if ($nbCol <= 0 || $total <= 0) { $nbCol = 1; $total = 1; }*/ $pdf = new TCPDF($pdf_orientation, PDF_UNIT, $pdf_format, true, 'UTF-8', false); $pdf->SetCreator("Woocommerce Products Designer by ORION"); $pdf->SetAuthor('Woocommerce Products Designer by ORION'); $pdf->SetTitle('Output'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins($pdf_margin_lr, $pdf_margin_tb, -1, true); $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); } $pdf->AddPage(); //$pdf->Image($input_file, '', '', '', '', '', false, 'C', false, 300, 'C', false, false, 0, false, false, false); $layers_id = 0; foreach ($layers_array as $layer) { $pdf->startLayer('layer' . $layers_id, true, true, false); $pdf->Image($layer, '', '', '', '', '', '', 'C', true, 300, 'C', false, false, 0, '', false, false); $pdf->endLayer(); $layers_id++; } // $defaultImageSize = getimagesize($img_output_file_path); // $pageWidth = $pdf->getPageWidth(); // $pagHeight = $pdf->getPageHeight(); // // $nblign = $total / $nbCol; // $marge = 10; // // //Set width and height // $w = ($pageWidth - $marge * ($nbCol + 1)) / $nbCol; // $h = ($defaultImageSize[1] * $w) / $defaultImageSize[0]; // if ($h * ($nblign + 1) + 20 > $pagHeight) { // $h = ($pagHeight - 2 * ($nblign + 1) - 20) / ($nblign + 1); // $w = ($defaultImageSize[0] * $h) / $defaultImageSize[1]; // $marge = ($pageWidth - ($w * $nbCol)) / ($nbCol + 1); // } // // //Print images // $x = $marge; // $y = 20; // $i = 0; // $layers_id = 0; // while ($i < $total) { // for ($i2 = 0; $i2 < $nbCol; $i2++) { // if ($i < $total) { // foreach ($layers_array as $layer) { // $pdf->startLayer('layer' . $layers_id, true, true, false); // $pdf->Image($layer, $x, $y, $w, $h, '', '', '', true, 300, '', false, false, 0, '', false, false); // $pdf->endLayer(); // $layers_id ++; // } // // $x += ($w + $marge); // $i ++; // } // } // $x = $marge; // $y += $h; // } $pdf->Output($output_file, 'F'); }
/* * setAlpha() gives transparency support. You can set the * alpha channel from 0 (fully transparent) to 1 (fully * opaque). It applies to all elements (text, drawings, * images). */ $pdf->SetLineWidth(2); // draw opaque red square $pdf->SetFillColor(255, 0, 0); $pdf->SetDrawColor(127, 0, 0); $pdf->Rect(30, 40, 60, 60, 'DF'); // set alpha to semi-transparency $pdf->SetAlpha(0.5); // draw green square $pdf->SetFillColor(0, 255, 0); $pdf->SetDrawColor(0, 127, 0); $pdf->Rect(50, 60, 60, 60, 'DF'); // draw blue square $pdf->SetFillColor(0, 0, 255); $pdf->SetDrawColor(0, 0, 127); $pdf->Rect(70, 80, 60, 60, 'DF'); // draw jpeg image $pdf->Image('images/image_demo.jpg', 90, 100, 60, 60, '', 'http://www.tcpdf.org', '', true, 72); // restore full opacity $pdf->SetAlpha(1); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_025.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
function showPdf($idReg = "") { global $db; // ------------------------------- // CONSULTA DE DATOS // ------------------------------- $sql = "select * from ENTRADA where id_entrada='{$idReg}'"; $db->query($sql); while ($db->next_record()) { $entSal = $db->f('ent_sal'); //$idCliente = $db->f('id_cliente'); //$cliente = getValueTable("cliente","CLIENTE","id_cliente",$idCliente); $cliente = $db->f('consig'); $idConte = $db->f('id_contenedor'); $conte = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte); if (preg_match("/(\\w{4})(\\d{7})/", $conte, $parts)) { $conteL = $parts[1]; $conteN = $parts[2]; } $idEq = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte); $equipo = getValueTable("equipo", "EQUIPO", "id_equipo", $idEq); $bkg = $db->f('bkg'); $clase = $db->f('clase'); $damage = $db->f('damage'); $sello = $db->f('sello'); $nota = $db->f('nota'); //$idTrans = $db->f('id_transporte'); //$transp = getValueTable("transporte","TRANSPORTE","id_transporte",$idTrans); $transp = $db->f('transportista'); $conteP1 = substr($conte, 0, 4); $conteP2 = substr($conte, 4, 10); if (preg_match("/(\\d+)(\\d)\$/", $conteP2, $parts)) { $conteP2 = $parts[1] . "-" . $parts[2]; } $idNav = $db->f('id_naviera'); $naviera = getValueTable("naviera", "NAVIERA", "id_naviera", $idNav); $placas = $db->f('placas'); // $idOperador = $db->f('id_operador'); //$operador = getValueTable("operador","OPERADOR","id_operador",$idOperador); $operador = $db->f('operador'); if ($entSal == "E") { $entCapFec = $db->f('cap_fec'); $entTrans = $transp; $entOpera = $operador; $entPlacas = $placas; $entClase = "CLASE : {$clase}"; $entDamage = $damage; $entSello = $sello; $entNota = $nota; } if ($entSal == "S") { $salCapFec = $db->f('cap_fec'); $salTrans = $transp; $salOpera = $operador; $salPlacas = $placas; $salClase = "CLASE : {$clase}"; $salDamage = $damage; $salSello = $sello; $salNota = $nota; } } // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', true, 'ISO-8859-1', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 009'); $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.' 009', PDF_HEADER_STRING); // 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); // $pdf->SetFooterMargin(3); $pdf->setPageOrientation('P', '', 1); //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 $pdf->setLanguageArray($l); // ------------------------------------------------------------------- $pdf->AddPage(); // Logo $pdf->setJPEGQuality(100); $pdf->Image('../images/logo_color.jpg', 13, 4, 25, 25, '', '', '', false); $pdf->Image('../images/nome.jpg', 15, 140, 185, 96, '', '', '', false); // set cell padding //$pdf->setCellPaddings(1, 1, 1, 1); // set cell margins //$pdf->setCellMargins(1, 1, 1, 1); $pdf->SetFillColor(197, 197, 197); // set font $txt = "TRANSPORTES MALEJA, S.A. DE C.V."; $pdf->SetFont('aefurat', '', 14); $pdf->MultiCell(65, 4, $txt, 0, 'L', 0, 0, 40, 10, true); // set font $txt = "Av. San Pablo s/n esq. Benito Juarez \nCol.San Pablo Xalpa Municipio Tlalnepantla \nC.P. 54090 Edo. de Mexico \nTels.: 5319-9375 5319-9228"; $pdf->SetFont('pdfahelvetica', '', 7); $pdf->MultiCell(60, 4, $txt, 0, 'C', 0, 0, 105, 10, true); $pdf->SetFont('pdfahelvetica', '', 12); $tbl = <<<EOD <table cellspacing="0" cellpadding="3" border="1" align="center"> <tr bgcolor="#cacaca"> <th>FOLIO</th> </tr> <tr> \t \t<td>{$idReg}</td> </tr> </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $txt = "RECIBO DE INTERCAMBIO DE EQUIPO (R.I.E)"; $pdf->SetFont('helvetica', 'B', 12); $pdf->MultiCell(100, 4, $txt, 0, 'C', 0, 0, 60, 37, true); $pdf->SetFont('helvetica', '', 8); $tbl = <<<EOD <br><br><br> <table cellspacing="0" cellpadding="3" border="1" align="center"> <tr> <th><b>CLIENTE</b></th> <th><b>MARCA</b></th> <th><b>NUMERO</b></th> <th><b>CARACTERISTICAS FISICAS</b></th> <th><b>LOCALIZACION</b></th> </tr> <tr> \t \t<td>{$cliente}</td> \t<td>{$conteL}</td> \t<td>{$conteN}</td> \t<td>{$equipo}</td> \t<td>{$localizacion}</td> </tr> <tr bgcolor="#cacaca"> \t<th colspan="3"><b>ENTRADA</b></th> \t<th colspan="2"><b>SALIDA</b></th> \t </tr> <tr> \t<td><b>ENTREGADO POR :</b></td> \t<td><b>FECHA Y HORA</b></td> \t<td><b>AUTORIZACION</b></td> \t<td><b>FECHA Y HORA</b></td> \t<td><b>DESTINO</b></td> </tr> <tr> \t<td>{$naviera}</td> \t<td>{$entCapFec}</td> \t<td>{$bkg}</td> \t<td>{$salCapFec}</td> \t<td> </td> </tr> <tr> \t<td><b>TRANSPORTISTA</b></td> \t<td><b><b>CARTA PORTE</b></b></td> \t<td><b>-</b></td> \t<td><b>TRANSPORTISTA</b></td> \t<td><b>CARTA PORTE</b></td> </tr> <tr> \t<td>{$entTrans}</td> \t<td>-</td> \t<td>-</td> \t<td>{$salTrans}</td> \t<td>-</td> </tr> <tr> \t<td><b>OPERADOR</b></td> \t<td><b>PLACAS</b></td> \t \t<td><b>-</b></td> \t \t<td><b>OPERADOR</b></td> \t<td><b>PLACAS</b></td> </tr>\t <tr> \t<td>{$entOpera}</td> \t<td>{$entPlacas}</td> \t<td>-</td> \t<td>{$salOpera}</td> \t<td>{$salPlacas}</td> </tr> <tr> \t<td><b>ESTADO FISICO</b></td> \t<td></td> \t<td></td> \t<td><b>ESTADO FISICO</b></td> \t<td></td> </tr> <tr> \t<td>{$entClase}</td> \t<td>{$entDamage}</td> \t<td>-</td> \t \t<td>{$salClase}</td> \t<td>{$salDamage}</td> </tr> <tr> \t<td colspan="3"><b>NO.SELLO</b></td> \t<td colspan="2"><b>NO.SELLO</b></td> </tr> <tr> \t<td colspan="3">{$entSello}</td> \t<td colspan="2">{$salSello}</td> </tr> <tr> \t<td colspan="3"><b>OBSERVACIONES</b></td> \t<td colspan="2"><b>OBSERVACIONES</b></td> </tr> <tr> \t<td colspan="3">{$entNota}</td> \t<td colspan="2">{$salNota}</td> </tr> </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $txt = "POR TRANSPORTISTA\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40, 10, $txt, 1, 'C', 0, 0, 15, 255, true); $txt = "POR DEPOSITO\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(30, 10, $txt, 1, 'C', 0, 0, 55, 255, true); $txt = "AUTO. DE REPARACION\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40, 10, $txt, 1, 'C', 0, 0, 85, 255, true); $txt = "POR TRANSPORTISTA\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40, 10, $txt, 1, 'C', 0, 0, 125, 255, true); $txt = "POR DEPOSITO\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(35, 10, $txt, 1, 'C', 0, 0, 165, 255, true); //Close and output PDF document $pdf->Output('example_eir.pdf', 'I'); }
$pdf->MultiCell(20, 1, "Status Perkawinan", 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(10, 1, ": {$ktp->status_nikah}", 0, 'L', 0, 1, '', '', true); $pdf->MultiCell(20, 1, 'Pekerjaan', 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(20, 1, ": {$ktp->pekerjaan}", 0, 'L', 0, 1, '', '', true); $pdf->MultiCell(20, 1, "Kewarganegaraan", 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(10, 1, ": {$ktp->wni}", 0, 'L', 0, 1, '', '', true); $dm = strftime(date('d-m', $dob)); $year = strftime(date('Y')); $year = (int) $year; $year += 5; $pdf->MultiCell(20, 1, "Berlaku Hingga", 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(15, 1, ": {$dm}-{$year}", 0, 'L', 0, 0, '', '', true); $pdf->Cell(20); $pdf->Cell(0, 1, "TULUNGAGUNG, " . strftime(date('m-F-Y')), 0, 1, 'C', 0, '', 0); $pdf->Cell(55); $pdf->Cell(0, 1, 'an. BUPATI TULUNGAGUNG', 0, 1, 'C', 0, '', 0); $pdf->Cell(55); $pdf->Cell(0, 1, 'KEPALA DINAS', 0, 1, 'C', 0, '', 0); $pdf->Cell(55); $pdf->Cell(0, 3, 'KEPENDUDUKAN DAN CATATAN SIPIL', 0, 1, 'C', 0, '', 0); // add foto image $pdf->Ln(5); $pdf->Cell(55); $pdf->Cell(0, 1, get_setting_value("kepala_capil"), 0, 1, 'C', 0, '', 0); $pdf->Image("../../statics/images/foto/{$ktp->photo}", 70, 15, 20, 25, '', '', 'C', true); $pdf->lastPage(); $pdf->Output('ktp.pdf', 'I'); } ?>
- To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12 - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes */ // set certificate file $certificate = 'file://../config/cert/tcpdf.crt'; // set additional information $info = array('Name' => 'TCPDF', 'Location' => 'Office', 'Reason' => 'Testing TCPDF', 'ContactInfo' => 'http://www.tcpdf.org'); // set document signature $pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info); // set font $pdf->SetFont('helvetica', '', 12); // add a page $pdf->AddPage(); // print a line of text $text = 'This is a <b color="#FF0000">digitally signed document</b> using the default (example) <b>tcpdf.crt</b> certificate.<br />To validate this signature you have to load the <b color="#006600">tcpdf.fdf</b> on the Arobat Reader to add the certificate to <i>List of Trusted Identities</i>.<br /><br />For more information check the source code of this example and the source code documentation for the <i>setSignature()</i> method.<br /><br /><a href="http://www.tcpdf.org">www.tcpdf.org</a>'; $pdf->writeHTML($text, true, 0, true, 0); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // *** set signature appearance *** // create content for signature (image and/or text) $pdf->Image('../images/tcpdf_signature.png', 180, 60, 15, 15, 'PNG'); // define active area for signature appearance $pdf->setSignatureAppearance(180, 60, 15, 15); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // *** set an empty signature appearance *** $pdf->addEmptySignatureAppearance(180, 80, 15, 15); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_052.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
function showPdf($idReg = "") { global $db; // Oficina //$sesIdOficina = $_SESSION[sesIdOficina]; //$oficina = getValueTable("oficina","OFICINA","id_oficina",$sesIdOficina); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', false, 'ISO-8859-1', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 009'); $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.' 009', PDF_HEADER_STRING); // 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); // $pdf->SetFooterMargin(3); $pdf->setPageOrientation('P', '', 1); //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 //$pdf->setLanguageArray($l); // set some language dependent data: $lg = array(); $lg['a_meta_charset'] = 'ISO-8859-1'; $lg['a_meta_dir'] = 'ltr'; $lg['a_meta_language'] = 'es'; $lg['w_page'] = 'page'; //set some language-dependent strings $pdf->setLanguageArray($lg); // ------------------------------- // CONSULTA DE DATOS // ------------------------------- $sql = "select * from SALIDA where id_salida='{$idReg}'"; $db->query($sql); while ($db->next_record()) { $docu = $db->f(doc_tipo); $docuRef = $db->f(doc_ref); $docTipo = $db->f(doc_tipo); //$entSal= $db->f('ent_sal'); $idSal = $idReg; $eir = $db->f(eir); $idOficina = $db->f(id_oficina); //$idCliente = $db->f('id_cliente'); //$cliente = getValueTable("cliente","CLIENTE","id_cliente",$idCliente); $cliente = $db->f('consig'); $idConte = $db->f('id_contenedor'); $conte = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte); if (preg_match("/(\\w{4})(\\d{7})/", $conte, $parts)) { $conteL = $parts[1]; $conteN = $parts[2]; } $maniStPago = $db->f(mani_st_pago); if ($maniStPago == "M") { $pagaManiobras = "MERCHANT"; } elseif ($maniStPago == "C") { $pagaManiobras = "CARRIER"; } $idEq = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte); $equipo = getValueTable("equipo", "EQUIPO", "id_equipo", $idEq); $bkg = $db->f('bkg'); $clase = $db->f('clase'); $clase = "CLASE: {$clase} "; $damage = $db->f('damage'); $sello = $db->f('sello'); $nota = $db->f('nota'); //$idTrans = $db->f('id_transporte'); //$transp = getValueTable("transporte","TRANSPORTE","id_transporte",$idTrans); $transp = $db->f('transportista'); $conteP1 = substr($conte, 0, 4); $conteP2 = substr($conte, 4, 10); if (preg_match("/(\\d+)(\\d)\$/", $conteP2, $parts)) { $conteP2 = $parts[1] . "-" . $parts[2]; } $idNav = $db->f('id_naviera'); $naviera = getValueTable("naviera", "NAVIERA", "id_naviera", $idNav); $placas = $db->f('placas'); // $idOperador = $db->f('id_operador'); //$operador = getValueTable("operador","OPERADOR","id_operador",$idOperador); $operador = $db->f('operador'); $capFec = $db->f('cap_fec'); $entSalTx = "SALIDA"; $tipoMani = $db->f('tipo_mani'); $noRecibo = $db->f('recibo'); if ($tipoMani == "D") { $tipoManiTx = "MANIOBRA DE DESCARGA"; } if ($tipoMani == "C") { $tipoManiTx = "MANIOBRA DE CARGA"; } $maniCosto = $db->f('mani_costo'); $repaCosto = $db->f('repa_costo'); $sumaCpto = $maniCosto + $repaCosto; $montoLetra = traducirCifra($sumaCpto); $capIdUsr = $db->f('cap_id_usr'); $capFec = $db->f('cap_fec'); $capUsr = getValueTable("usuario", "USUARIO", "id_usuario", $capIdUsr); $modFec = $db->f('mod_fec'); $consig = $db->f('consig'); } // ------------------------------ // DAÑOS // ------------------------------ $sql = "select * from REL_NOME_SAL_PLUS "; $sql .= "where id_salida='{$idSal}' "; $dano = ""; $db->query($sql); while ($db->next_record()) { $idRelNome = $db->f(id_rel_nome); $idNome = $db->f(id_nome); $idUbica = $db->f(id_ubicacion); $idDime = $db->f(id_dimension); $nome = getValueTable("nombre", "NOMENCLATURA", "id_nome", $idNome); $nomeCode = getValueTable("codigo", "NOMENCLATURA", "id_nome", $idNome); $ubica = getValueTable("ubicacion", "UBICACION", "id_ubicacion", $idUbica); $dimen = getValueTable("dimension", "DIMENSION", "id_dimension", $idDime); $dano .= "{$nome} ({$nomeCode}) : {$ubica} : {$dimen}\n"; } $dano = nl2br($dano); // --------------------------------------------------------- // DATOS DEL RECIBO // --------------------------------------------------------- if ($noRecibo > 0) { $subTotal = $maniCosto + $repaCosto; $total = $subTotal; $subTotal = number_format($subTotal, 2); $total = number_format($total, 2); $datoRecibo = "\n <table cellspacing=\"0\" cellpadding=\"3\" border=\"1\" align=\"center\"> \n <tr>\n <td colspan=\"4\" valign=\"middle\"><b>DEPOSITO DE CONTENEDORES OPEMANTRA</b></td>\n <td>\n <table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" align=\"center\"> \n <tr>\n <td bgcolor=\"black\"><b><font color=\"white\">FOLIO</font></b></td>\n </tr>\n <tr>\n <td><font color=\"red\"><b>No. {$noRecibo}</b></font></td>\n </tr>\n </table>\n </td>\n </tr> \n <tr>\n <td><b>FECHA</b></td>\n <td><b>No.R.I.E.</b></td> \n <td></td>\n <td><b>CONTENEDOR</b></td>\n <td><b>TIPO</b></td>\n </tr>\n <tr>\n <td>{$capFec}</td> \n <td>{$idReg}</td>\n <td></td>\n <td>{$conteL}{$conteN}</td>\n <td>{$equipo}</td>\n </tr> \n <tr>\n <td><b>CONCEPTO</b></td> \n <td><b>TRANSPORTISTA</b></td> \n <td><b>OPERADOR</b></td>\n <td colspan=\"2\"><b>OBSERVACIONES</b></td> \n </tr> \n <tr> \n <td>{$tipoManiTx}</td> \n <td>{$transp}</td>\n <td>{$operador}</td> \n <td colspan=\"2\">{$docu} {$docuRef} / {$nota}</td> \n </tr>\n </table>\n <table cellspacing=\"0\" cellpadding=\"3\" border=\"1\" align=\"center\">\n <tr>\n <td ><b>FIRMA OPERADOR</b></td>\n <td ><b>FIRMA DEL DEPOSITO</b></td>\n <td>\n <table cellspacing=\"0\" cellpadding=\"3\" border=\"1\" align=\"center\">\n <tr>\n <td align=\"right\"><b>MANIOBRA \$</b></td>\n <td align=\"right\">{$maniCosto}</td>\n </tr>\n <tr>\n <td align=\"right\"><b>REPARACIONES \$</b></td>\n <td align=\"right\">{$repaCosto}</td>\n </tr> \n <tr>\n <td align=\"right\"><b>TOTAL \$</b></td>\n <td align=\"right\">{$total}</td>\n </tr>\n </table>\n </td>\n </tr>\n "; if ($docTipo == "EFECTIVO") { $datoRecibo .= "\n <tr> \n <td colspan=\"3\" align=\"right\">RECIBIMOS DE <u>{$operador}</u> LA CANTIDAD DE {$montoLetra} PESOS M.N. 00/100 </td>\n </tr>\n "; } $datoRecibo .= "</table>"; } // ------------------------------------------------------------------- $pdf->AddPage(); // Logo $pdf->setJPEGQuality(100); $pdf->Image('../images/logo.jpg', 13, 4, 60, 30, '', '', '', false); //$pdf->Image('../images/nome.jpg', 15, 145, 185, 120,'','','',false); // set cell padding $pdf->setCellPaddings(1, 1, 1, 1); // set cell margins $pdf->setCellMargins(1, 1, 1, 1); // Encabezado $pdf->SetFillColor(197, 197, 197); // Trebol $pdf->SetFont('helvetica', '', 14); $pdf->MultiCell(65, 4, $txt, 0, 'L', 0, 0, 40, 10, true); //$txt="Av. "; $pdf->SetFont('helvetica', '', 7); $pdf->MultiCell(60, 4, $txt, 0, 'C', 0, 0, 105, 10, true); $pdf->SetFont('helvetica', '', 12); $tbl = <<<EOD <table cellspacing="0" cellpadding="3" border="0" align="center"> <tr bgcolor="#cacaca"> <th>FOLIO</th> </tr> <tr> \t \t<td><font color="red">S {$eir}</font></td> </tr> </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $txt = "RECIBO DE INTERCAMBIO DE EQUIPO (R.I.E)"; $pdf->SetFont('helvetica', 'B', 12); $pdf->MultiCell(100, 4, $txt, 0, 'C', 0, 0, 60, 37, true); $pdf->SetFont('helvetica', '', 8); $tbl = <<<EOD <br><br><br> <table cellspacing="0" cellpadding="3" border="0" align="center"> <tr> <th><b>CONTENEDOR</b></th> <th><b>CARACTERISTICAS FISICAS</b></th> <td><b>CLIENTE</b></td> <td><b>PAGA MANIOBRAS</b></td> </tr> <tr> \t<td>{$conteL}{$conteN}</td> \t<td>{$equipo} / {$damage} </td> \t<td>{$consig}</td> <td>{$pagaManiobras}</td> </tr> <tr bgcolor="#cacaca"> \t<th colspan="4"><b>{$entSalTx}</b></th> </tr> <tr> \t<td><b>NAVIERA</b></td> \t<td><b>FECHA Y HORA</b></td> <td><b>BOOKING / BL</b></td> \t<td><b>ESTADO FISICO</b></td> \t </tr> <tr> \t<td>{$naviera}</td> \t<td>{$capFec}</td> <td>{$bkg}</td> \t<td>{$clase}</td> \t </tr> <tr> \t<td><b>TRANSPORTISTA</b></td> <td><b>OPERADOR</b></td> <td><b>PLACAS</b></td> \t<td><b>SELLO</b></td> \t \t </tr>\t <tr> \t<td>{$transp}</td> <td>{$operador}</td> <td>{$placas}</td> <td>{$sello}</td> </tr> <tr > \t<td colspan="2"><b>OBSERVACIONES</b></td> \t <td colspan="2"><b>DANOS</b></td> </tr> <tr > <td colspan="2">{$nota}</td> \t<td colspan="2">{$dano}</td> </tr> <tr> <td><b>OPERADOR<br><br><br>Nombre y Firma</b></td> <td><b>INSPECTOR<br><br><br>Nombre y Firma</b></td> <td colspan="2">EMISION DE FACTURA DENTRO DE LOS 5 DIAS POSTERIORES A LA REALIZACIÓN DE SU SERVICIO PASADO ESTE TIEMPO NO HABRÁ EMISIÓN DE FACTURAS.</td> </tr> <tr bgcolor="#cacaca"> <td colspan="4"><i>Capturo: {$capUsr}<br>Fecha captura: {$modFec} </i></td> </tr> </table> <br><br><br> <!-- {$datoRecibo} --> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); /* ($noRecibo>0)?$corY=180:$corY=125; $txt="OPERADOR\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(40,10,$txt, 0, 'C',0, 0, 15, $corY,true); $txt="INSPECTOR\n\n\nNOMBRE Y FIRMA"; $pdf->MultiCell(30, 10,$txt, 0, 'C',0, 0, 55, $corY,true); $txt="EMISION DE FACTURA DENTRO DE LOS 5 DIAS POSTERIORES A LA REALIZACIÓN DE SU SERVICIO PASADO ESTE TIEMPO NO HABRÁ EMISIÓN DE FACTURAS. Solicitarla al correo: factu@demo.com.mx"; $pdf->MultiCell(105, 10,$txt, 0, 'L',0, 0, 95, $corY,true); $txt="EMISION DE FACTURA DENTRO DE LOS 5 DIAS POSTERIORES A LA REALIZACIÓN DE SU SERVICIO PASADO ESTE TIEMPO NO HABRÁ EMISIÓN DE FACTURAS. Solicitarla al correo: facturacionpatios@demo.com.mx"; */ //($noRecibo>0)?$corY=200:$corY=125; //$pdf->MultiCell(185, 10,$txt, 1, 'C',0, 0, 15, 200,true); //Close and output PDF document $pdf->Output('eirSalida.pdf', 'I'); }
/** * @param string $filename * @param float|string $x * @param float|string $y * @param float|string $width * @param float|string $height * @param array $attrs { * @option string "align" optional default is "left" * @option string "valign" optional default is "top" * } * @see http://www.tcpdf.org/doc/code/classTCPDF.html */ public function drawImage($filename, $x, $y, $width, $height, array $attrs = array()) { $position = $this->buildImagePosition($attrs); $this->pdf->Image($filename, $x, $y, $width, $height, null, null, null, true, 300, null, false, false, 0, $position); }
$pdf->AddPage(); // set color for text stroke $pdf->SetDrawColor(255, 0, 0); $pdf->setTextRenderingMode($stroke = 0, $fill = true, $clip = false); $pdf->Write(0, 'Fill text', '', 0, '', true, 0, false, false, 0); $pdf->setTextRenderingMode($stroke = 0.2, $fill = false, $clip = false); $pdf->Write(0, 'Stroke text', '', 0, '', true, 0, false, false, 0); $pdf->setTextRenderingMode($stroke = 0.2, $fill = true, $clip = false); $pdf->Write(0, 'Fill, then stroke text', '', 0, '', true, 0, false, false, 0); $pdf->setTextRenderingMode($stroke = 0, $fill = false, $clip = false); $pdf->Write(0, 'Neither fill nor stroke text (invisible)', '', 0, '', true, 0, false, false, 0); // * * * CLIPPING MODES * * * * * * * * * * * * * * * * * * $pdf->StartTransform(); $pdf->setTextRenderingMode($stroke = 0, $fill = true, $clip = true); $pdf->Write(0, 'Fill text and add to path for clipping', '', 0, '', true, 0, false, false, 0); $pdf->Image('../images/image_demo.jpg', 15, 65, 170, 10, '', '', '', true, 72); $pdf->StopTransform(); $pdf->StartTransform(); $pdf->setTextRenderingMode($stroke = 0.3, $fill = false, $clip = true); $pdf->Write(0, 'Stroke text and add to path for clipping', '', 0, '', true, 0, false, false, 0); $pdf->Image('../images/image_demo.jpg', 15, 75, 170, 10, '', '', '', true, 72); $pdf->StopTransform(); $pdf->StartTransform(); $pdf->setTextRenderingMode($stroke = 0.3, $fill = true, $clip = true); $pdf->Write(0, 'Fill, then stroke text and add to path for clipping', '', 0, '', true, 0, false, false, 0); $pdf->Image('../images/image_demo.jpg', 15, 85, 170, 10, '', '', '', true, 72); $pdf->StopTransform(); $pdf->StartTransform(); $pdf->setTextRenderingMode($stroke = 0, $fill = false, $clip = true); $pdf->Write(0, 'Add text to path for clipping', '', 0, '', true, 0, false, false, 0); $pdf->Image('../images/image_demo.jpg', 15, 95, 170, 10, '', '', '', true, 72);
public function MakePDF($sender, $param) { $stringJob = $this->formatJob($param->Item->IDJobColumn->Text); $job = TblStringingJobs::finder()->findBy_id($param->Item->IDJobColumn->Text); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor("www.stringtools.it"); $pdf->SetTitle($stringJob); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set font $pdf->SetFont('times', '', 13); // add a page $pdf->AddPage(); //immagine utente $urlJpg = 'themes/White/images/logo/' . $this->User->UserDB->id . ".jpg"; //$urlPng = 'themes/White/images/logo/'.$this->User->UserDB->id.".png"; if (file_exists($urlJpg)) { $pdf->Image($urlJpg, 10, 6, 40, 15, 'JPG', 'www.stringtools.it', '', true, 150, '', false, false, 0); } else { $pdf->Image('themes/White/images/logo-st-www.jpg', 10, 6, 40, 15, 'JPG', 'www.stringtools.it', '', true, 150, '', false, false, 0); } //$pdf->Image('themes/White/images/logo-st-www.jpg',10,6,40, '', '', 'http://www.tcpdf.org', '', false, 300); $pdf->Ln(15); $pdf->Cell(0, 0, $this->User->UserDB->surname . " " . $this->User->UserDB->name, 0, 1, 'L', 0, '', 0); if ($this->User->UserDB->telephone != "") { $pdf->Cell(0, 0, $this->User->UserDB->telephone, 0, 1, 'L', 0, '', 1); } if ($this->User->UserDB->mobile_telephone != "") { $pdf->Cell(0, 0, $this->User->UserDB->mobile_telephone, 0, 1, 'L', 0, '', 1); } if ($this->User->UserDB->email != "") { $pdf->Cell(0, 0, $this->User->UserDB->email, 0, 1, 'L', 0, '', 1); } $pdf->Ln(10); $pdf->Cell(0, 0, date("d-m-Y"), 0, 1, 'R', 0, '', 1); $pdf->Ln(10); $pdf->SetFont('times', '', 16); $pdf->Cell(0, 0, Prado::localize('CLAIM_CHECK'), 0, 1, 'C', 0, '', 1); $pdf->Ln(10); $pdf->SetFont('times', '', 13); $pdf->writeHTML($this->makeHtmlJob($job), true, false, true, false, ''); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="' . $stringJob . '.pdf"'); $pdf->Output($stringJob . '.pdf', 'D'); }
// set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(0, 0, PDF_MARGIN_RIGHT); //PDF_MARGIN_LEFT, 0, PDF_MARGIN_RIGHT); //PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor // $pdf->setImageScale(1); //PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- $pdf->setJPEGQuality(100); $pdf->Image("{$config['http_home_url']}/engine/modules/pdf_forms/zp_form_1.jpg", 0, 0, 210, 295, '', '', '', true, 150, '', false, false, 0, false, false); $pdf->SetFont('times', '', 12); $pdf->TextField('person_name', 105, 6, array(), array('v' => iconv("cp1251", "utf-8", trim($_POST['person_name'])), 'Q' => 1), 55, 38.5); $pdf->TextField('person_name_old', 148, 6, array(), array('v' => iconv("cp1251", "utf-8", trim($_POST['person_name_old'])), 'Q' => 1), 13, 45.5); $pdf->TextField('person_birthday', 91, 6, array(), array('v' => iconv("cp1251", "utf-8", trim($_POST['person_birthday'])), 'Q' => 1), 61, 55); $pdf->TextField('person_sex', 30, 6, array(), array('v' => iconv("cp1251", "utf-8", trim($_POST['person_sex'])), 'Q' => 1), 164.5, 55); $pdf->TextField('person_birth_address', 150, 5, array(), array('v' => iconv("cp1251", "utf-8", trim($_POST['person_birth_address'])), 'q' => 1), 44.5, 62); $line1 = ""; $line2 = ""; $line1_full = false; $token = strtok($_POST['person_address'], " "); while ($token != false) { if (strlen($line1) + strlen($token) < 50 && !$line1_full) { if (strlen($line1) > 0) { $line1 = $line1 . ' '; }