本文整理汇总了PHP中FPDI::SetTextColor方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::SetTextColor方法的具体用法?PHP FPDI::SetTextColor怎么用?PHP FPDI::SetTextColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::SetTextColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_philosophy_certificate
function generate_philosophy_certificate($confirmation, $form, $entry, $ajax)
{
// print_r( $entry ); die;
if ($entry['gquiz_is_pass']) {
$upload_dir = wp_upload_dir();
// initiate FPDI
$pdf = new FPDI();
// set the sourcefile
$pdf->setSourceFile(get_template_directory() . '/library/certificate.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// get the width and height of the template
$specs = $pdf->getTemplateSize($tplIdx);
// add a page
$pdf->AddPage("L", array($specs['w'], $specs['h']));
// use the imported page as the template
$pdf->useTemplate($tplIdx, 0, 0);
// now write some text above the imported page
$pdf->SetY(101);
$pdf->SetFont("dejavuserifbi", 'I', 35);
$pdf->SetTextColor(0, 54, 99);
$text = $entry['2.3'] . " " . $entry['2.6'];
$pdf->MultiCell(260, 40, $text, 0, 'C');
// now write some text above the imported page
$pdf->SetY(165);
$pdf->SetFont("dejavuserifbi", 'I', 22);
$pdf->SetTextColor(0, 54, 99);
$text = date('F j, Y');
$pdf->MultiCell(260, 22, $text, 0, 'C');
// save the pdf out to file
$pdf->Output($upload_dir['basedir'] . '/certificates/' . $entry['id'] . '.pdf', 'F');
}
return array('redirect' => '/philosophy-results/?id=' . $entry['id']);
}
示例2: runProcessStep
public function runProcessStep($dokument)
{
$file = $dokument->getLatestRevision()->getFile();
$extension = array_pop(explode(".", $file->getExportFilename()));
#$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename());
// Print Metainfo for PDFs
if (strtolower($extension) == "pdf") {
try {
$fpdf = new FPDI();
$pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename());
$fpdf->SetMargins(0, 0, 0);
$fpdf->SetFont('Courier', '', 8);
$fpdf->SetTextColor(0, 0, 0);
$documentSize = null;
for ($i = 0; $i < $pagecount; $i++) {
$string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")";
$fpdf->AddPage();
$tpl = $fpdf->importPage($i + 1);
$size = $fpdf->getTemplateSize($tpl);
// First Page defines documentSize
if ($documentSize === null) {
$documentSize = $size;
}
// Center Template on Document
$fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true);
$fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string);
}
$this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S"));
} catch (Exception $e) {
$this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
}
} else {
$this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
}
}
示例3: generate_mitgliedsbescheinigung
function generate_mitgliedsbescheinigung($titleAndName, $strasse, $plz, $ort, $land, $jahr, $vorstand, $datum)
{
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile(HOME_DIRECTORY . 'alumpiHP_libraries/Mitgliedsbestaetigung_blank.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at position 0,0 with a width of 210 mm (full page)
$pdf->useTemplate($tplIdx, 0, 0, 210);
// add the font DejaVu
$pdf->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true);
$pdf->AddFont('DejaVuSans-Bold', '', 'DejaVuSans-Bold.ttf', true);
// text settings
$pdf->SetTextColor(0, 0, 0);
// add address of the member
$addressString = $titleAndName . "\n";
$addressString .= $strasse . "\n";
$addressString .= $plz . " " . $ort . "\n";
$addressString .= $land;
$pdf->SetFont('DejaVuSans');
$pdf->SetFontSize(12);
$pdf->SetXY(20, 23);
$pdf->Multicell(80, 6, $addressString);
//add heading
$headingString = "Mitgliedsbescheinigung " . $jahr;
$pdf->SetFont('DejaVuSans-Bold');
$pdf->SetFontSize(16);
$pdf->SetXY(20, 80);
$pdf->Multicell(170, 6, $headingString);
// add main text
$textString = "Hiermit wird bestätigt, dass " . $titleAndName . " im Kalenderjahr " . $jahr;
$textString .= " ordentliches Mitglied des Absolventen- und Förderverein MPI Uni Bayreuth e.V. (aluMPI) ist.\n";
$textString .= "\n";
$pdf->SetFont('DejaVuSans');
$pdf->SetFontSize(12);
$pdf->SetXY(20, 100);
$pdf->Multicell(170, 6, $textString);
// add signature text
$signatureString = "Absolventen- und Förderverein MPI Uni Bayreuth e.V.\n";
$signatureString .= "1. Vorstand: " . $vorstand . "\n";
$pdf->SetXY(20, 140);
$pdf->Multicell(170, 6, $signatureString);
// add signature
$pdf->Image(HOME_DIRECTORY . 'alumpiHP_libraries/unterschrift_krinninger.png', 20, 155, 50);
// add place and date
$dateString = "Bayreuth, " . $datum;
$pdf->SetXY(20, 180);
$pdf->Multicell(170, 6, $dateString);
ob_clean();
$pdf->Output();
}
示例4: listAction
public function listAction()
{
$receipt = new \FPDI();
// PDFの余白(上左右)を設定
$receipt->SetMargins(0, 0, 0);
// ヘッダーの出力を無効化
$receipt->setPrintHeader(false);
// フッターの出力を無効化
$receipt->setPrintFooter(false);
// フォントを登録
$fontPathRegular = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-regular.ttf';
// $regularFont = $receipt->addTTFfont($fontPathRegular, '', '', 32);
$font = new TCPDF_FONTS();
$regularFont = $font->addTTFfont($fontPathRegular);
$fontPathBold = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-bold.ttf';
// $boldFont = $receipt->addTTFfont($fontPathBold, '', '', 32);
$font = new TCPDF_FONTS();
$boldFont = $font->addTTFfont($fontPathBold);
// ページを追加
$receipt->AddPage();
// テンプレートを読み込み
// $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/receipt.pdf');
// $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/template.pdf');
// $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/w01_1.pdf');
$receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/senijiten.pdf');
// 読み込んだPDFの1ページ目のインデックスを取得
$tplIdx = $receipt->importPage(1);
// 読み込んだPDFの1ページ目をテンプレートとして使用
$receipt->useTemplate($tplIdx, null, null, null, null, true);
// 書き込む文字列のフォントを指定
$receipt->SetFont($regularFont, '', 11);
// 書き込む文字列の文字色を指定
$receipt->SetTextColor(0, 0, 255);
// X : 42mm / Y : 108mm の位置に
$receipt->SetXY(59, 248);
// 文字列を書き込む
$receipt->Write(0, isset($_POST['name']) ? $_POST['name'] . 'さん' : '名無しさん');
/* $response = new Response(
// Output関数の第一引数にはファイル名、第二引数には出力タイプを指定する
// 今回は文字列で返してほしいので、ファイル名はnull、出力タイプは S = String を選択する
$receipt->Output(null, 'S'),
200,
array('content-type' => 'application/pdf')
);
// レスポンスヘッダーにContent-Dispositionをセットし、ファイル名をreceipt.pdfに指定
$response->headers->set('Content-Disposition', 'attachment; filename="receipt.pdf"');
return $response;
*/
// $receipt->
$receipt->output('newpdf.pdf', 'I');
}
示例5: array
function schedule_retirement_pay($date_retired = '', $employee_id = '1')
{
$data = array();
$data['msg'] = '';
$this->load->library('fpdf');
if (!defined('FPDF_FONTPATH')) {
define('FPDF_FONTPATH', $this->config->item('fonts_path'));
}
$this->load->library('fpdi');
// initiate FPDI
$pdf = new FPDI('L', 'mm', 'Legal');
$pdf->SetAutoPageBreak(FALSE);
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('dtr/template/leave/schedule_retirement_pay.pdf');
// select the first page
$tplIdx = $pdf->importPage(1);
// use the page we imported
$pdf->useTemplate($tplIdx);
$e = new Employee_m();
$e->get_by_employee_id($employee_id);
// set font, font style, font size.
$pdf->SetFont('Times', '', 10);
$pdf->SetTextColor(89, 89, 89);
// set initial placement
$pdf->SetXY(142, 20.5);
$personal = new Personal_m();
$personal->where('employee_id', $e->id);
$personal->get(1);
$this->load->helper('date');
$o = new Office_m();
$o->get_by_office_id($e->office_id);
$period = 'January 1, 2012 May 10, 2012';
$office_name = $o->office_name;
$lgu_name = Setting::getField('lgu_name');
//var_dump($date_retired);
$date_retired_diff = $date_retired;
$date_birth = convert_long_date($personal->birth_date, TRUE);
$first_day_of_service = convert_long_date($e->first_day_of_service);
$date_retired = convert_long_date($date_retired, TRUE);
$salary = $this->Salary_grade->get_monthly_salary($e->salary_grade, $e->step);
//$pdf->SetX(114);
$pdf->Write(0, $period);
$pdf->Ln(10);
$pdf->SetX(63);
$pdf->Write(0, $office_name);
$pdf->Ln(5);
$pdf->SetX(63);
$pdf->Write(0, $lgu_name);
$pdf->SetFont('Times', 'B', 10);
$pdf->Ln(21.5);
$pdf->SetX(14);
$pdf->Write(0, $e->fname . ' ' . substr($e->mname, 0, 1) . '. ' . $e->lname);
$pdf->SetFont('Times', '', 10);
$pdf->SetX(65);
$pdf->Write(0, $date_birth);
$pdf->SetX(88);
$pdf->Write(0, $date_retired);
$date1 = new DateTime("1970-7-01");
$date2 = new DateTime("2011-11-16");
$date1 = new DateTime($e->first_day_of_service);
$date2 = new DateTime($date_retired_diff);
$interval = $date1->diff($date2);
//echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";
if ($interval->y != 0) {
$pdf->SetX(114);
$pdf->Write(0, $interval->y . " years");
}
if ($interval->m != 0) {
$pdf->Ln(5);
$pdf->SetX(114);
$pdf->Write(0, $interval->m . " months");
}
if ($interval->d != 0) {
$pdf->Ln(5);
$pdf->SetX(114);
$pdf->Write(0, $interval->d . " days");
}
// Salary
$pdf->SetXY(145, 53);
$pdf->Cell(20, 8, number_format($salary, 2), '', 0, 'C', FALSE);
$total_leave = $this->Leave_card->get_total_leave_credits($employee_id);
$vacation_leave = $total_leave['vacation'];
$sick_leave = $total_leave['sick'];
$total = $vacation_leave + $sick_leave;
$terminal_leave = $salary * $total * 0.0478087;
// vacation leave
$pdf->SetXY(203, 58);
$pdf->Cell(20, 8, number_format($vacation_leave, 3), '', 0, 'R', FALSE);
// sick leave
$pdf->SetXY(203, 63);
$pdf->Cell(20, 8, number_format($sick_leave, 3), '', 0, 'R', FALSE);
// total
$pdf->SetXY(203, 68);
$pdf->Cell(20, 8, number_format($total, 3), '', 0, 'R', FALSE);
// terminal leave
$pdf->SetX(274);
$pdf->Cell(20, 8, number_format($terminal_leave, 2), '', 0, 'R', FALSE);
$pdf->SetFont('Times', 'B', 10);
//.........这里部分代码省略.........
示例6: SetHTMLTextColor
private function SetHTMLTextColor($htmlHex)
{
parent::SetTextColor(hexdec(substr($htmlHex, 0, 2)), hexdec(substr($htmlHex, 2, 2)), hexdec(substr($htmlHex, 4, 2)));
}
示例7: view_sign_oc
public function view_sign_oc(){
require_once('./assets/fpdf17/fpdf.php');
require_once('./assets/fpdf17/fpdi.php');
$oc_id=$this->uri->segment(3,'');
// init pce data
$oc_dat=$this->m_oc->get_oc_by_id($oc_id);
$project=$this->m_project->get_project_by_id($oc_dat->project_id);
//init sign pic
$ae_sign_user_dat=$this->m_user->get_user_by_login_name($project->project_cs);
$ae_sign_filename="no";
if (isset($ae_sign_user_dat->sign_filename)) {
$ae_sign_filename=$ae_sign_user_dat->sign_filename;
}
$finance_sign_dat=$this->m_user->get_user_by_login_name($oc_dat->fc_sign);
$finance_sign_filename="no";
if (isset($finance_sign_dat->sign_filename)) {
$finance_sign_filename=$finance_sign_dat->sign_filename;
}
// initiate FPDI
$pdf = new FPDI();
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','','angsa.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','B','angsab.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','I','angsai.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','BI','angsaz.php');
// get the page count
$pageCount = $pdf->setSourceFile("./media/real_pdf/".$oc_dat->filename);
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('angsana','B',14);
$pdf->SetXY(5, 5);
//$pdf->Write(8, 'A complete document imported with FPDI');
//// temporaly disable
if ($finance_sign_filename!="no"&&$finance_sign_filename!=""&&$finance_sign_filename!=null) {
//$pdf->Image("./media/sign_photo/".$finance_sign_filename,100,10,40,0);
}
if ($ae_sign_filename!="no"&&$ae_sign_filename!=""&&$ae_sign_filename!=null) {
//$pdf->Image("./media/sign_photo/".$ae_sign_filename,100,110,40,0);
}
//$pdf->Image("images/play.png",100,100,100,0);
}
$new_filename=$oc_dat->oc_no."_A.pdf";
// Output the new PDF
//@unlink("./media/real_pdf/".$new_filename);
$pdf->Output($new_filename,"I");
//redirect("media/real_pdf/".$new_filename);
}
示例8: FPDI
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 ----------------------------------
//.........这里部分代码省略.........
示例9: DateTime
require 'fpdf.php';
require 'fpdi.php';
header('Content-Type: text/pdf; charset=UTF-8');
$dni = $_POST["tbDni"];
$nombre = $_POST["tbNombre"];
$fecha = (new DateTime())->format("dd/mm/YY");
$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("diploma-plantilla.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, 0, 0, 0, 0, true);
$pdf->SetFont('Helvetica', "", 12);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY(30, 80);
$pdf->write(0, utf8_decode("La Universidad de La Rioja otorga el siguiente diploma a"));
$pdf->SetFont('Helvetica', "", 20);
$pdf->SetTextColor(255, 10, 10);
$pdf->SetXY(30, 90);
$pdf->write(0, utf8_decode(utf8_encode($nombre)));
$pdf->SetFont('Helvetica', "", 12);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY(30, 100);
$pdf->write(0, utf8_decode("Con dni: " . $dni . " ha superado con éxito el programa formativo,"));
$pdf->SetFont('Helvetica', "", 25);
$pdf->SetTextColor(255, 30, 30);
$pdf->SetXY(30, 110);
$pdf->write(0, utf8_decode("CURSO DE MANIPULACIÓN DE PDF"));
$pdf->SetFont('Helvetica', "", 12);
示例10: foreach
$pdf->Ln(6);
$pdf->write(15, ' ' . $clie['email']);
$products = $facadeProyecto->obtenerDatoProductoProyecto($_GET['proNum']);
$pdf->Ln(15);
$pdf->SetFontSize(15);
$pdf->SetFont('Arial', 'B');
$pdf->write(15, ' Productos Solicitados:');
$pdf->SetFontSize(11);
if (!empty($products)) {
$pdf->Ln(12);
$pdf->write(15, ' ' . utf8_decode('Código ') . 'Nombre Producto ' . 'Cantidad ' . '% Ganancia ' . 'IVA ');
$j = 200;
foreach ($products as $productos) {
$pdf->Ln(8);
if ($productos['cantidadProductos'] != 0) {
$pdf->SetTextColor(97, 97, 97);
$pdf->SetXY(35, $j);
$pdf->Write(0, $productos['idProductos']);
$pdf->SetXY(53, $j);
$pdf->Write(0, $productos['nombreProducto']);
$pdf->SetXY(91, $j);
$pdf->Write(0, $productos['cantidadProductos'] . '/Uni.');
$pdf->SetXY(115, $j);
$pdf->Write(0, $productos['ganancia'] . '%');
$pdf->SetXY(141, $j);
$pdf->Write(0, $productos['iva']);
$j = $j + 6;
}
}
}
//enviamos cabezales http para no tener problemas
示例11: FlyerRendering
//.........这里部分代码省略.........
// 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);
}
示例12: generatepdfAction
public function generatepdfAction(command $commande)
{
$request = $this->get('request');
$tools = $this->get('tools.utils');
$session = $request->getSession();
if ($session->has('tpl')) {
$tpl = $commande->getToprint();
$pdffile = "";
foreach ($tpl as $key => $elemnt) {
foreach ($elemnt as $val) {
$prod = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($val['id']);
$template = $prod->getTpl();
$tplpdf = str_replace("../", "", $template->getPdf());
$pdffile = $this->get('kernel')->getRootDir() . '/../web/' . $tplpdf;
}
}
$custom_layout = array(85, 55);
$orientation = 'L';
$pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->SetMargins(0, 0, 0);
$pdf->SetAutoPageBreak(true, 0);
$pdf->setFontSubsetting(false);
$pdf->AddPage($orientation);
// echo "<pre>";print_r($pdf->getMargins());exit;
$pdf->setSourceFile($pdffile);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, 0, 0, 85, 55, true);
$idd = "";
$i = 0;
$oldx = 0;
$oldy = 0;
foreach ($elemnt as $value) {
//if($i==0)
if ($idd != $value['id'] && $value['value'] != "") {
$pdf->SetPageMark();
if (substr($value['value'], 0, 4) != "/tmp") {
//$tools->dump($value);
$align = strtoupper(substr($value['align'], 0, 1));
$color = $this->hex2rgb($value['color']);
$pdf->SetTextColor($color[0], $color[1], $color[2]);
$param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']);
$y2 = $param->getX1() / 5;
$x1 = $param->getY1() / 5;
//$x1 = 10;$y2 = 8;
$w = $param->getX2() / 5;
$h = $param->getY2() / 5;
$oldx = $x1;
$oldy = $y2;
$pdf->SetX($x1, false);
$pdf->SetY($y2, false);
//$pdf->SetXY($x1, $y2,true);
$pdf->SetFont(null, '', $param->getSize() * 0.6);
//$param->getPolice()
// echo $opt->getFontsize()."\n";
$pdf->Cell($w, $h, $value["value"], 0, 0, $align);
} else {
$param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']);
$img = $this->getParameter('base_url') . $value['value'];
$pdf->Image($img, $param->getX1() / 4.5, $param->getY1() / 4.55, $param->getX2() / 4.55, $param->getY2() / 4.5, '', '', '', true);
}
}
$idd = $value['id'];
$i++;
}
//$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
// echo $template->getId();
$pdf->Output($this->get('kernel')->getRootDir() . '/../web/pdf.pdf');
}
return new Response("");
}
示例13: FPDI
// for changes in this section.
//====================================================================
$pdf = new FPDI();
$pdf->AddPage();
// import the template PFD
$pdf->setSourceFile($filename);
// select the first page
$tplIdx = $pdf->importPage(1);
// use the page we imported
$pdf->useTemplate($tplIdx);
//====================================================================
// Write to the document
//====================================================================
// set font, font style, font size.
$pdf->SetFont('Arial', '', 6);
$pdf->SetTextColor(0, 51, 102);
// set initial placement
$pdf->SetXY(27, 15);
// line break
//$pdf->Ln(5);
// go to 25 X (indent)
$pdf->SetX(27);
// write
$pdf->SetFont('Arial', '', 10);
$pdf->Write(0, utf8_decode($ObtenerCabeceraFacturacion[0]['nombreCliente']));
// move to next line
$pdf->Ln(5);
$pdf->SetFont('Arial', '', 7);
// The following section is basically a repetition of the previous for inserting more text.
// repeat for more text:
$pdf->SetX(27);
示例14: preview
function preview($employee_id)
{
$this->load->helper('settings');
$this->load->library('fpdf');
//define('FPDF_FONTPATH',$this->config->item('fonts_path'));
$this->load->library('fpdi');
//$pi = new Personal();
//$pi->get_by_employee_id( $employee_id );
//print_r($personal_info);
// initiate FPDI
$pdf = new FPDI('P', 'mm', 'Letter');
// add a page
$pdf->AddPage();
// set the sourcefile
//$pdf->setSourceFile('dtr/template/service_record/service_record.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, 1, 1, 210);
// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY(15, 60);
$pdf->SetFont('Arial', '', 16);
$pdf->Cell(0, 3, "Employee's Service Record", '', 1, 'C', false);
$pdf->Ln(4);
$e = new Employee_m();
$e->get_by_id($employee_id);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 8, "Employee No.:" . $e->employee_id, '', 1, 'L', false);
$pdf->Ln(2);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 8, "Employee Name:" . $e->lname . ', ' . $e->fname . ' ' . $e->mname, '', 1, 'L', false);
$pdf->Ln(4);
$pdf->Cell(0, 8, "Date From Date To Position Department Movement Status Status", '1', 1, 'L', false);
$pdf->Ln(4);
$work = new Work();
$work->where('govt_service', '1');
$work->order_by('inclusive_date_from', 'DESC');
$works = $work->get_by_employee_id($employee_id);
$i = 1;
$this->load->helper('text');
foreach ($works as $work) {
$pdf->SetFont('Arial', '', 8);
$pdf->SetX(10);
list($year, $month, $day) = explode('-', $work->inclusive_date_from);
$inclusive_date_from = $month . '/' . $day . '/' . $year;
$pdf->Write(0, $inclusive_date_from);
list($year, $month, $day) = explode('-', $work->inclusive_date_to);
$inclusive_date_to = $month . '/' . $day . '/' . $year;
if ($work->inclusive_date_to == 'Present') {
$inclusive_date_to = 'Present';
}
$pdf->SetX(29);
$pdf->Write(0, $inclusive_date_to);
$pdf->SetFont('Arial', '', 8);
$pdf->SetX(50);
$pdf->Write(0, str_replace('…', '..', character_limiter($work->position, 35)));
$pdf->SetX(100);
//$pdf->Write(0, $work->company);
$pdf->Write(0, str_replace('…', '..', character_limiter($work->company, 35)));
//$pdf->SetFont('Arial', '', 12);
$pdf->SetX(160);
$pdf->Write(0, $work->movement);
//$pdf->SetX(150);
//$pdf->Write(0, $work->salary_grade);
$pdf->SetFont('Arial', '', 8);
$pdf->SetX(185);
$pdf->Write(0, $work->status);
$work->govt_service = $work->govt_service == 1 ? 'Yes' : 'No';
$pdf->SetX(190);
//$pdf->Write(0, $work->govt_service);
$pdf->SetFont('Arial', '', 12);
if ($i == 6 || $i == 10 || $i == 13 || $i == 16 || $i == 19 || $i == 22) {
$pdf->Ln(8);
} else {
$pdf->Ln(7);
}
$i++;
}
$pdf->Cell(0, 8, "--------------------------------------------------------- Nothing Follows ---------------------------------------------------------", '', 1, 'C', false);
// Signatories
$pdf->Ln(15);
$pdf->SetX(20);
$pdf->Cell(90, 5, "PREPARED BY:", '0', 0, 'C', false);
$pdf->Cell(90, 5, "CERTIFIED CORRECT:", '0', 1, 'C', false);
$pdf->Ln(10);
$sr_prepared = Setting::getField('sr_prepared');
$sr_prepared_position = Setting::getField('sr_prepared_position');
$sr_certified = Setting::getField('sr_certified');
$sr_certified_position = Setting::getField('sr_certified_position');
$pdf->SetX(20);
$pdf->Cell(90, 5, $sr_prepared, '0', 0, 'C', false);
//4th param border
$pdf->Cell(90, 5, $sr_certified, '0', 1, 'C', false);
$pdf->SetX(20);
$pdf->Cell(90, 5, $sr_prepared_position, '0', 0, 'C', false);
$pdf->Cell(90, 5, $sr_certified_position, '0', 1, 'C', false);
// Output
$pdf->Output('dtr/template/service_record/archives/service_record_' . $employee_id . '.pdf', 'I');
//.........这里部分代码省略.........
示例15: test
public function test()
{
// $rgb_arr = sscanf('rgb(243, 243, 243)', "rgb(%d, %d, %d)");
// print_r($this->rgbToCmyk($rgb_arr[0], $rgb_arr[1], $rgb_arr[2]));
// exit();
//
$img = new Imagick('test.jpg');
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setresolution(300, 300);
$img->setimageformat('pdf');
$img->writeimage('test.pdf');
include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
include_once APPPATH . 'libraries/tcpdf/fpdi.php';
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile('test.pdf');
$pdf->SetMargins(0, 0, 0, true);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
// установим опции для pdf
$pdf->SetMargins(0, 0, 0, true);
$pdf->setCellHeightRatio(1);
$pdf->setCellPaddings(0, 0, 0, 0);
$pdf->setCellMargins(1, 1, 1, 1);
$pdf->SetAutoPageBreak(false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->Image('qwe.png', 30, 30, 20, '', '', '', '', false, 300);
$pdf->SetTextColor(0, 0, 0, 100);
$pdf->SetFont('helvetica', 'BI', 10, '', 'false');
$pdf->Text(12, 9, 'Black CMYK');
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/uploads/fynal.pdf', 'F');
$im = new Imagick();
$im->setResolution(300, 300);
$im->readimage('uploads/fynal.pdf[0]');
$im->setImageFormat('jpeg');
$im->resizeimage(538, 360, Imagick::FILTER_LANCZOS, 1);
$im->writeImage('uploads/fynal.jpg');
$im->clear();
$im->destroy();
// include_once APPPATH . 'libraries/drawer.php';
//
// $drawer = new Drawer();
// $drawer->init();
// $drawer->setLayout();
// $drawer->setBackground('test.jpg');
// $drawer->drawImage('test.jpg', 10, 10, 30);
// $drawer->drawText('Maxim', 10, 10, 'TimesNewRoman', 20, 'rgb(77, 77, 77)');
// $drawer->savePdf($_SERVER['DOCUMENT_ROOT'] . '/1.pdf');
// $drawer->makePreview($_SERVER['DOCUMENT_ROOT'] . '/1.pdf', $_SERVER['DOCUMENT_ROOT'] . '/1.jpg');
}