本文整理汇总了PHP中FPDF::SetLeftMargin方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDF::SetLeftMargin方法的具体用法?PHP FPDF::SetLeftMargin怎么用?PHP FPDF::SetLeftMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDF
的用法示例。
在下文中一共展示了FPDF::SetLeftMargin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPdf
function getPdf($image)
{
require JPATH_SITE . "/components/com_flexpaper/fpdf/fpdf.php";
$filePath = JPATH_SITE . "/components/com_flexpaper/output/certificate.pdf";
$pdf = new FPDF('L', 'mm');
$pdf->SetLeftMargin(0);
$pdf->SetRightMargin(0);
$pdf->SetTopMargin(0);
$pdf->SetAutoPageBreak(false);
$pdf->AddPage();
$pdf->Image($image);
$pdf_file = $pdf->Output($filePath, 'F');
return $pdf_file;
}
示例2: etichette
function etichette()
{
$db = new db_local();
$sqlqry = "SELECT * FROM anagrafiche WHERE (a" . date("Y") . "=1 OR a" . (date("Y") - 1) . "=1) AND idcapo=0 and email = '' AND carica != 'NS' AND tiposocio IN ('SF','SO','SS') ORDER BY cognome,nome;";
if ($db->query($sqlqry)) {
require_once 'lib/fpdf/fpdf.php';
$pdf = new FPDF();
$pdf->SetMargins(0.5, 5, 1);
$pdf->SetAutoPageBreak(true, 3);
$pdf->AddPage('P', 'mm', 'A4');
//$pdf->Cell(210,5,'',1,1);
$intVar = 1;
//$intX = $pdf->GetX();
$intX = 0.5;
$intY = $pdf->GetY();
while ($db->next_record()) {
$pdf->SetLeftMargin($intX);
$pdf->SetXY($intX, $intY);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(75, 6, ' ', '', 1, 'L');
$pdf->Cell(75, 6, ' ' . $db->record['cognome'] . ' ' . $db->record['nome'], '', 1, 'L');
$pdf->SetFont('Arial', '', 10);
$pdf->Cell(75, 6, ' ' . $db->record['via'], '', 1, 'L');
$pdf->SetFont('Arial', '', 8);
/*
$pdf->Cell(53,6,$db->record['cap'],'',1,'L');
$pdf->Cell(10,6,' ','',0,'L');
$pdf->Cell(53,6,$db->record['cap'].' - '.$db->record['citta'].' ('.$db->record['prov'].')','',1,'L');
*/
$pdf->Cell(75, 6, ' ' . $db->record['cap'] . ' - ' . $db->record['citta'] . ' (' . $db->record['prov'] . ')', '', 1, 'L');
$pdf->Cell(75, 12, ' ', '', 1, 'L');
if ($intVar < 3) {
$intX = $intX + 70;
$intY = $pdf->GetY() - 36;
} else {
$intX = 0;
$intY = $pdf->GetY();
$intVar = 0;
}
$intVar++;
}
$pdf->Output();
}
}
示例3: drawPDF
public function drawPDF()
{
$pdf = new \FPDF('P', 'mm', 'Letter');
if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
$this->font = 'Gill';
$this->alt_font = 'GillBook';
define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
$pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
$pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
}
$width = 52;
// tag width in mm
$height = 31;
// tag height in mm
$left = 6;
// left margin
$top = 16;
// top margin
$pdf->SetTopMargin($top);
//Set top margin of the page
$pdf->SetLeftMargin($left);
//Set left margin of the page
$pdf->SetRightMargin($left);
//Set the right margin of the page
$pdf->SetAutoPageBreak(False);
// manage page breaks yourself
$data = $this->loadItems();
$num = 0;
// count tags
$x = $left;
$y = $top;
foreach ($data as $item) {
// extract & format data
$price = $item['normal_price'];
$desc = strtoupper(substr($item['posDescription'], 0, 25));
$brand = ucwords(strtolower(substr($item['brand'], 0, 13)));
$pak = $item['units'];
$size = $item['units'] . "-" . $item['size'];
$sku = $item['sku'];
$ppu = $item['pricePerUnit'];
$vendor = substr($item['vendor'], 0, 7);
$upc = $item['upc'];
if ($num % 32 == 0) {
$pdf->AddPage();
$x = $left;
$y = $top;
} else {
if ($num % 4 == 0) {
$x = $left;
$y += $height;
}
}
$pdf->SetFont($this->font, '', 8);
$pdf->SetXY($x, $y);
// try normal wordwrap
// but squeeze into two lines if needed
$wrapped = wordwrap($desc, 12, "\n", true);
if (count(explode("\n", $wrapped)) > 2) {
$wrapped = substr($desc, 0, 12);
if ($wrapped[11] != ' ') {
$wrapped .= '-';
}
$wrapped .= "\n";
$wrapped .= trim(substr($desc, 12));
}
$pdf->MultiCell($width / 2, 3, $wrapped, 0, 'L');
$pdf->SetX($x);
$pdf->Cell($width / 2, 3, date('n/j/y ') . $size, 0, 1, 'L');
$pdf->SetFont($this->font, 'B', 18);
//change font for price
$pdf->SetX($x);
$pdf->Cell($width / 2, 8, $price, 0, 1, 'L');
$args = array('height' => 7, 'align' => 'L', 'fontsize' => 8, 'width' => 0.23, 'font' => $this->font);
$b_y = $pdf->GetY();
$pdf = $this->drawBarcode($upc, $pdf, $x, $b_y, $args);
// move right by tag width
$x += $width;
$num++;
}
$pdf->Output('Tags4x8P.pdf', 'I');
}
示例4: createContentFile
function createContentFile($mod, $statement, $uid, $bild)
{
//Erzeugung der pdf-Galerie
//echo "Statement in Fkt: ".$statement;
//$statement fuer exif, desc, zeit, kat(ausser Wurzel) uebergeben
include '../share/global_config.php';
include $sr . '/bin/share/db_connect1.php';
switch ($mod) {
case 'geo':
$statement = explode(' ', $statement);
//
$num100 = count($statement);
break;
default:
$result100 = mysql_query("{$statement}");
@($num100 = mysql_num_rows($result100));
break;
}
if ($statement !== '') {
//echo $statement;
//echo "gefundene Bilder: ".$num100."<BR>";
//memory_limit dynamisch anpassen, falls der berechnete Wert groesser als der vorhandene Wert ist.
$steps = ceil($num100 / 100);
//echo "<font color='white'>".$steps." - </font>";
$memory_avail = ini_get('memory_limit');
$memory_value = $steps * 50;
if ($memory_value > $memory_avail) {
$memory = $memory_value . "M";
ini_set('memory_limit', $memory);
}
//echo "<font color='white'>".ini_get('memory_limit')."</font>";
$seiten = floor($num100 / 20) + 1;
define('FPDF_FONTPATH', '../share/fpdf/font/');
require $sr . '/bin/share/fpdf/fpdf.php';
$pdf = new FPDF('P', 'mm', 'A4');
$pdf->SetLeftMargin(20);
$pdf->SetFont('Arial', '', 10);
$aktdatum = date('d.m.Y');
for ($seite = '0'; $seite < $seiten; $seite++) {
$pdf->AddPage();
$pdf->Cell(0, 5, 'pic2base-Galerie', 0, 1, 'C');
$pdf->Cell(0, 5, 'Tipp: Mit einem Klick auf den Dateinamen erhalten Sie die vergr' . utf8_decode(ö) . 'sserte Ansicht des betreffenden Bildes.', 0, 1, 'C');
for ($zeile = '0'; $zeile < '5'; $zeile++) {
$y_mitte = 50 + $zeile * 48;
for ($spalte = '0'; $spalte < '4'; $spalte++) {
$x_mitte = 45 + $spalte * 45;
//Ermittlung des QH-/Ori-Dateinamens und der Bild-Masse
$zaehler = $spalte + $zeile * 4 + $seite * 20;
if ($zaehler < $num100) {
//echo $zaehler;
switch ($mod) {
case 'geo':
switch ($bild) {
case '0':
$result102 = mysql_query("SELECT * FROM {$table2} WHERE pic_id = '{$statement[$zaehler]}'");
$FileNameV = mysql_result($result102, 0, 'FileNameV');
//$FileNameHQ = mysql_result($result102, $zaehler, 'FileNameHQ');
@($parameter_v = getimagesize($sr . '/images/vorschau/thumbs/' . $FileNameV));
break;
case '1':
$result102 = mysql_query("SELECT * FROM {$table2} WHERE pic_id = '{$statement[$zaehler]}'");
$FileNameHQ = mysql_result($result102, 0, 'FileNameHQ');
@($parameter_v = getimagesize($sr . '/images/vorschau/hq-preview/' . $FileNameHQ));
break;
}
$FileName = mysql_result($result102, 0, 'FileName');
break;
default:
switch ($bild) {
case '0':
$FileNameV = mysql_result($result100, $zaehler, 'FileNameV');
$FileNameHQ = mysql_result($result100, $zaehler, 'FileNameHQ');
@($parameter_v = getimagesize($sr . '/images/vorschau/thumbs/' . $FileNameV));
break;
case '1':
$FileNameHQ = mysql_result($result100, $zaehler, 'FileNameHQ');
@($parameter_v = getimagesize($sr . '/images/vorschau/hq-preview/' . $FileNameHQ));
break;
}
$FileName = mysql_result($result100, $zaehler, 'FileName');
break;
}
$breite = $parameter_v[0];
$hoehe = $parameter_v[1];
//echo $hoehe." / ";
if ($hoehe !== '0' and $hoehe !== "" and $hoehe !== NULL) {
$ratio = $breite / $hoehe;
if ($ratio > '1') {
//Breitformat
$Breite = 40;
$Hoehe = number_format($Breite / $ratio, 0, '.', ',');
} else {
//Hochformat
$Hoehe = 40;
$Breite = number_format($Hoehe * $ratio, 0, '.', ',');
}
$x0 = $x_mitte - $Breite / 2;
$y0 = $y_mitte - $Hoehe / 2;
switch ($bild) {
case '0':
//.........这里部分代码省略.........
示例5: genSalon
function genSalon()
{
global $options;
# paramètres
$mg = 5;
// Marge de gauche => initial 17
$mh = 4;
// Marge du haut => initial 9
$md = 15;
// Marge de droite
$mb = 9;
// Marge du bas
$largeur_etiquette = 42;
// largeur_etiquette => initial 60
$espace_etiquettes = 13;
// => initial 7
$nb_ligne_etiquettes = 4;
$nb_etiquette_ligne = 5;
// Préparation du document PDF.
$pdf = new FPDF('L', 'mm', 'A4');
$pdf->Open();
$pdf->SetLeftMargin($mg);
$pdf->SetTopMargin($mh);
$pdf->SetAutoPageBreak(1, 0);
$pdf->AddPage();
// Gestion des fonts
$pdf->AddFont('code39', '', 'IDAutomation_Code_39.php');
$pdf->SetFont('times', '', 12);
// Préparation des informations.
$nom = strtoupper($this->patient->getNom());
$prenom = strtoupper($this->patient->getPrenom());
$date = new clDate($this->patient->getDateNaissance());
$duree = new clDuree();
$dateN = $date->getDate("d/m/Y");
$dateN .= " (" . $duree->getAge($date->getTimestamp()) . ")";
if ($this->patient->getSexe() == "F") {
$sexe = "Féminin";
$e = "e";
} elseif ($this->patient->getSexe() == "M") {
$sexe = "Masculin";
$e = "";
} else {
$sexe = "Indéterminé";
$e = "";
}
$date->setDate($this->patient->getDateAdmission());
$le = $date->getDate("d/m/Y H:i");
$led = $date->getDate("d/m/Y");
$leh = $date->getDate("H:i");
$ipp = $this->patient->getILP();
$nsej = $this->patient->getNSej();
$uf = $this->patient->getUF();
$sexe = $this->patient->getSexe();
if ($uf == $options->getOption('numUFexec')) {
$loc = '(URGENCES)';
} else {
$loc = '(UHCD)';
}
$tel = $this->patient->getTel();
$adresse = $this->patient->getAdresse();
$cpv = $this->patient->getCodePostal() . " " . $this->patient->getVille();
$prev = $this->patient->getPrevenir();
$medt = $this->patient->getMedecinTraitant();
$modet = $this->patient->getMedecinTraitant();
$adresseur = $this->patient->getAdresseur();
$modeadm = $this->patient->getModeAdmission();
// Grosse étiquette
$pdf->Cell(20, 4, "", 0, 0, L);
// Ligne 1
$pdf->Cell(4 * $largeur_etiquette, 5, "CENTRE HOSPITALIER DE CARPENTRAS", 0, 1, L);
// Ligne 2
$pdf->Cell(11, 5, "Date : ", 0, 0, L);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(23, 5, "{$led}", 0, 0, L);
$pdf->SetFont('times', '', 12);
$pdf->Cell(13, 5, "Heure : ", 0, 0, L);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(27, 5, "{$leh}", 0, 0, L);
$pdf->SetFont('times', '', 12);
$pdf->Cell(21, 5, "N° Patient : ", 0, 0, L);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(22, 5, "{$ipp}", 0, 0, L);
$pdf->SetFont('times', '', 12);
$pdf->Cell(18, 5, "N° URG : ", 0, 0, L);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(22, 5, "{$nsej}", 0, 0, L);
$pdf->SetFont('times', '', 12);
$pdf->Cell(18, 5, "N° ARCHIVE : ", 0, 1, L);
// Ligne 3
$pdf->Cell(11, 5, "Nom : ", 0, 0, L);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(63, 5, strtoupper($nom), 0, 0, L);
$pdf->SetFont('times', '', 12);
$pdf->Cell(13, 5, "Nom naissance : ", 0, 1, L);
// Ligne 4
$pdf->Cell(16, 5, "Prénom : ", 0, 0, L);
$pdf->SetFont('times', 'B', 12);
$pdf->Cell(58, 5, ucfirst(strtolower($prenom)), 0, 0, L);
$pdf->SetFont('times', '', 12);
$pdf->Cell(12, 5, "Sexe : ", 0, 0, L);
//.........这里部分代码省略.........
示例6: FPDF
function __construct($products, $order, $filename, $save = false)
{
App::import('vendor', 'fpdf/fpdf');
$orientation = 'P';
$unit = 'pt';
$format = 'A4';
$margin = 40;
$pdf = new FPDF($orientation, $unit, $format);
App::import('Helper', 'Time');
$timeHelper = new TimeHelper();
setlocale(LC_MONETARY, 'th_TH');
$pdf->AddPage();
$pdf->SetTopMargin($margin);
$pdf->SetLeftMargin($margin);
$pdf->SetRightMargin($margin);
$pdf->SetAutoPageBreak(true, $margin);
$pdf->SetY($pdf->GetY() + 60);
$pdf->SetFont('Arial', 'B', 10);
$pdf->SetTextColor(0);
$pdf->SetFillColor(255);
$pdf->SetLineWidth(1);
$pdf->Cell(50, 25, "Order ID: ", 'LT', 0, 'L');
$pdf->SetFont('Arial', '');
$pdf->Cell(50, 25, $order['Order']['id'], 'T', 0, 'L');
$pdf->SetFont('Arial', 'B');
$pdf->Cell(100, 25, 'Customer Name: ', 'T', 0, 'L');
$pdf->SetFont('Arial', '');
$pdf->Cell(316, 25, $order['User']['name'], 'TR', 1, 'L');
$pdf->SetFont('Arial', 'B');
$pdf->Cell(100, 25, "Delivery Date: ", 'LT', 0, 'L');
$pdf->SetFont('Arial', '');
$pdf->Cell(416, 25, $timeHelper->format($format = 'd-m-Y', $order['Delivery']['date']), 'TR', 1, 'L');
$pdf->SetFont('Arial', 'B', '10');
$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$cell_width = 30;
$pdf->MultiCell($cell_width, 25, "No.\n ", 'LTR', 'C');
$pdf->SetXY($current_x + $cell_width, $current_y);
$pdf->Cell(250, 25, "Description", 'LTR', 0, 'C');
$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$cell_width = 48;
$pdf->MultiCell($cell_width, 25, "Number Ordered", 'LTR', 'C');
$pdf->SetXY($current_x + $cell_width, $current_y);
$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$cell_width = 48;
$pdf->MultiCell($cell_width, 25, "Number Supplied", 'LTR', 'C');
$pdf->SetXY($current_x + $cell_width, $current_y);
$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$cell_width = 70;
$pdf->MultiCell($cell_width, 25, "Amount per Unit", 'LTR', 'C');
$pdf->SetXY($current_x + $cell_width, $current_y);
$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$cell_width = 70;
$pdf->MultiCell($cell_width, 25, "Amount\n ", 'LTR', 'C');
$pdf->SetY($pdf->GetY() - 25);
$pdf->SetFont('Arial', '');
$pdf->SetFillColor(238);
$pdf->SetLineWidth(0.2);
$pdf->SetY($pdf->GetY() + 25);
$num = 1;
$number_ordered = 0;
$number_supplied = 0;
foreach ($products as $product) {
$pdf->Cell(30, 20, $num++, 1, 0, 'L');
$pdf->Cell(250, 20, $product['Product']['short_description'], 1, 0, 'L');
$pdf->Cell(48, 20, $product['LineItem']['quantity'], 1, 0, 'R');
$number_ordered += $product['LineItem']['quantity'];
$pdf->Cell(48, 20, $product['LineItem']['quantity_supplied'], 1, 0, 'R');
$number_supplied += $product['LineItem']['quantity_supplied'];
$pdf->Cell(70, 20, money_format("%i", $product['Product']['selling_price']), 1, 0, 'R');
$pdf->Cell(70, 20, money_format("%i", $product['LineItem']['total_price_supplied']), 1, 1, 'R');
}
$pdf->SetX($pdf->GetX() + 30);
$pdf->SetFont('Arial', 'B');
$pdf->Cell(250, 20, "TOTALS", 1);
$pdf->SetFont('Arial', '');
$pdf->Cell(48, 20, $number_ordered, 1, 0, 'R');
$pdf->Cell(48, 20, $number_supplied, 1, 0, 'R');
$pdf->Cell(70, 20, "N.A.", 1, 0, 'R');
$pdf->Cell(70, 20, money_format("%i", $order['Order']['total_supplied']), 1, 1, 'R');
$pdf->SetY($pdf->GetY() + 25);
$pdf->SetFont('Arial', 'B');
$pdf->Cell(80, 20, "Amount Paid: ");
$pdf->SetFont('Arial', '');
$pdf->Cell(80, 20, money_format("%i", $order['Order']['total']), 0, 1);
$pdf->SetFont('Arial', 'B');
$pdf->Cell(80, 20, "Actual Amount: ");
$pdf->SetFont('Arial', '');
$pdf->Cell(80, 20, money_format("%i", $order['Order']['total_supplied']), 0, 1);
$pdf->SetFont('Arial', 'B');
$pdf->Cell(80, 20, "Rebate Amount: ");
$pdf->SetFont('Arial', '');
$pdf->Cell(80, 20, money_format("%i", $order['Order']['total'] - $order['Order']['total_supplied']), 0, 1);
if ($save) {
$pdf->Output($filename, 'F');
} else {
//.........这里部分代码省略.........
示例7: PrintTickets
/**
* Print tickets as PDF documents
* Tickets can be printed for an event, a single occurrence,
* or all tickets for a user ID.
*
* @param string $ev_id Event ID
* @param integer $rp_id Repeat ID
* @param integer $uid User ID
* @return string PDF Document containing tickets
*/
public static function PrintTickets($ev_id = '', $rp_id = 0, $uid = 0)
{
global $_CONF;
$checkin_url = $_CONF['site_admin_url'] . '/plugins/evlist/checkin.php?tic=';
// get the tickets, paid and unpaid. Need event id and uid.
$tickets = self::GetTickets($ev_id, $rp_id, $uid);
// The PDF functions in lgLib are a recent addition. Make sure that
// the lgLib version supports PDF creation since we can't yet check
// the lglib version during installation
if (empty($tickets) || !function_exists('USES_lglib_class_fpdf')) {
return "There are no tickets available to print";
}
USES_lglib_class_fpdf();
USES_evlist_class_repeat();
USES_evlist_class_tickettype();
$ev_id = NULL;
// create params array for qrcode, if used
$params = array('module_size' => 5);
$pdf = new FPDF();
$pdf->SetLeftMargin(20);
$pdf->AddPage();
$tic_types = array();
foreach ($tickets as $tic_id => $ticket) {
if (!isset($tick_types[$ticket->tic_type])) {
$tick_types[$ticket->tic_type] = new evTicketType($ticket->tic_type);
}
// If we don't already have the event info, get it and construct
// the address string
if ($ev_id != $ticket->ev_id) {
$Ev = new evEvent($ticket->ev_id);
$ev_id = $Ev->id;
$addr = array();
if ($Ev->Detail->street != '') {
$addr[] = $Ev->Detail->street;
}
if ($Ev->Detail->city != '') {
$addr[] = $Ev->Detail->city;
}
if ($Ev->Detail->province != '') {
$addr[] = $Ev->Detail->province;
}
if ($Ev->Detail->country != '') {
$addr[] = $Ev->Detail->country;
}
if ($Ev->Detail->postal != '') {
$addr[] = $Ev->Detail->postal;
}
$address = implode(' ', $addr);
}
// Get the repeat(s) for the ticket(s) to print a ticket for each
// occurrence.
$repeats = evRepeat::GetRepeats($ticket->ev_id, $ticket->rp_id);
foreach ($repeats as $rp_id => $event) {
$ev_date = $event->date_start;
$ev_time = $event->time_start1 . ' - ' . $event->time_end1;
if (!empty($event->time_start2)) {
$ev_time .= '; ' . $event->time_start1 . ' - ' . $event->time_end2;
}
$fee = self::formatAmount($ticket->fee);
// Get the veritcal position of the current ticket
// for positioning the qrcode
$y = $pdf->GetY();
// Title
$pdf->SetFont('Times', 'B', 12);
$pdf->Cell(130, 10, "{$tick_types[$ticket->tic_type]->description}: {$Ev->Detail->title}", 1, 0, 'C');
$pdf->Ln(13);
$pdf->SetFont('Times', '', 12);
$pdf->SetX(-40);
$pdf->Cell(0, 30, 'Fee: ' . $fee);
if ($ticket->fee > 0) {
$pdf->Ln(5);
if ($ticket->paid >= $ticket->fee) {
$pdf->SetX(-40);
$pdf->Cell(0, 30, 'Paid');
} else {
$pdf->SetX(-55);
$due = $ticket->fee - $ticket->paid;
$pdf->Cell(0, 30, 'Balance Due: ' . self::formatAmount($due));
}
}
$pdf->SetX(20);
$pdf->Cell(0, 8, "Date:", 0, 0);
$pdf->setX(40);
$pdf->Cell(0, 8, $ev_date, 0, 1);
$pdf->Cell(0, 6, "Time:", 0, 0);
$pdf->SetX(40);
$pdf->Cell(0, 6, $ev_time, 0, 1);
if ($Ev->Detail->location != '') {
$pdf->Ln(5);
$pdf->Cell(0, 2, 'Where: ', 0, 0);
//.........这里部分代码省略.........
示例8: xml2pdf
/**
* Генерирует PDF-документ на основании XML-файла.
*
* @param string $file Файл для обработки
* @param mixed $replacements массив для подстановки значений
* @return FPDF сформированный документ PDF или FALSE в случае неудачи
*/
public static function xml2pdf($file, $replacements = false)
{
// Новая обработка PDF
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/odt2pdf.php';
$tpl = basename($file, ".xml") . ".odt";
$t = new odt2pdf($tpl);
$t->convert($replacements);
return $t;
/**
* @deprecated
*/
if (!file_exists($file)) {
return false;
}
require_once dirname(__FILE__) . '/fpdf/fpdf.php';
define('FPDF_FONTPATH', dirname(__FILE__) . '/fpdf/font/');
if (is_array($replacements)) {
foreach ($replacements as &$val) {
$val = htmlspecialchars_decode($val, ENT_QUOTES);
}
}
$replacements['$tab'] = ' ';
$xml = new DOMDocument('1.0', 'windows-1251');
$xml->load($file);
$pdf = new FPDF();
// Загружаем шрифты
$pdf->AddFont('ArialMT', '', 'c9bb7ceca00657d007d343f4e34b71a8_arial.php');
$pdf->AddFont('Arial-BoldMT', '', '9cb9fc616ba50d7ecc7b816984f2ffda_arialbd.php');
$pdf->AddFont('TimesNewRomanPSMT', '', '5f37f1915715e014ee2254b95c0b6cab_times.php');
$pdf->AddFont('TimesNewRomanPS-BoldMT', '', 'e07f6c05a47ebec50a80f29789c7f1f6_timesbd.php');
/*
Загружаем XML-документ и читаем из него основные параметры лоя итогового PDF-документа
*/
$root = $xml->documentElement;
$title = $root->getAttribute('title') ? iconv('windows-1251', 'utf-8', $root->getAttribute('title')) : '';
// заголовок документа
$author = $root->getAttribute('author');
// автор
$margin_left = $root->getAttribute('margin-left') ? $root->getAttribute('margin-left') : 20;
// отступ слева
$margin_right = $root->getAttribute('margin-right') ? $root->getAttribute('margin-right') : 20;
// отступ справа
$margin_top = $root->getAttribute('margin-top') ? $root->getAttribute('margin-top') : 20;
// отступ сверху
$font_name = $root->getAttribute('font-name') ? $root->getAttribute('font-name') : 'ArialMT';
// дефолтный шрифт (имя)
$font_size = (int) $root->getAttribute('font-size') ? (int) $root->getAttribute('font-size') : 10;
// дефолтный шрифт (размер)
$text_width = (int) $root->getAttribute('width') ? (int) $root->getAttribute('width') : 170;
// ширина печатной области документа
$paragraph_indent = (int) $root->getAttribute('paragraph-indent') ? (int) $root->getAttribute('paragraph-indent') : 0;
// отступ между параграфами
$printable = $pdf->h - $margin_top - 20;
$pdf->SetTitle($title, true);
$pdf->SetAuthor($author);
$pdf->SetLeftMargin($margin_left);
$pdf->SetRightMargin($margin_right);
$pdf->SetTopMargin($margin_top);
$pdf->AddPage();
$pdf->SetFont($font_name, '', $font_size);
$pdf->SetX($margin_left);
$locates = array();
// разбор XML-документа
$xpath = new DOMXPath($xml);
$scale = $xpath->query('/document/page/*');
if ($scale->length) {
$footer = $xpath->query('//footer');
$footer = $footer->length ? $footer->item(0) : NULL;
$no_brake = $xpath->query('//nobreak');
$no_brake = $no_brake->length ? TRUE : FALSE;
// если есть теги <nobreak>, то расставляем разрывы страниц руками
if ($no_brake) {
$pdf->SetAutoPageBreak(false);
}
$last_y = 0;
$pages = array();
foreach ($scale as $node) {
$last_y = intval($pdf->y);
if ($node->tagName == 'nobreak' && $node->getAttribute('start')) {
$max_h = $last_y;
$loc_offset = 0;
foreach ($xpath->query('//cell|locate[(following::nobreak)]') as $i => $nd) {
if ($nd->tagName == 'nobreak' && $node->getAttribute('end')) {
break;
}
$_h = $nd->getAttribute('height');
if ($i > 0 && !$loc_offset) {
$_h = 0;
}
$max_h += intval($_h);
$loc_offset = $nd->getAttribute('x_offset');
}
$max_h += $last_y;
//.........这里部分代码省略.........
示例9: generar_pdf
public function generar_pdf($id_cor, $id_direccion_gen)
{
$correspondencia = $this->ivss_model->core_parcial($id_cor)->result();
$direccion_general = $this->ivss_model->ver_direccion_general_especifica($id_direccion_gen);
foreach ($correspondencia as $cor_item) {
$id_cor_oficio = $cor_item->id_cor;
$num_control_oficio = $cor_item->num_control;
$dir_origen_oficio = $cor_item->dir_origen;
$remitente_oficio = $cor_item->remitente;
$dir_destino_oficio = $cor_item->dir_destino;
$asunto_oficio = $cor_item->asunto;
$descripcion_oficio = $cor_item->descripcion;
$fecha_crea_oficio = $cor_item->fecha_creacion;
}
$datos_director = $this->ivss_model->ver_dir_gen_especifica2($dir_destino_oficio)->result();
foreach ($datos_director as $dir) {
$nombre_director = $dir->nombre_director;
$resolucion_director = $dir->resolucion_director;
}
$this->load->library('fpdf/fpdf');
$pdf = new FPDF('P');
$pdf->AddPage();
$pdf->SetTitle("correspondencia", true);
$pdf->SetFont('Arial', 'B', 16);
$pdf->Image($this->config->base_url() . 'fronted/img/banner_institucional.png', 20, 8, 170);
$pdf->AliasNbPages();
$pdf->SetSubject("Sistema de correspondencia");
$pdf->Image($this->config->base_url() . 'fronted/img/logogrande.png', 20, 25, 17);
$pdf->SetFont('Arial', '', 9);
$pdf->Text(68, 30, "REPUBLICA BOLIVARIANA DE VENEZUELA");
$pdf->Text(42, 40, "MINISTERIO DEL PODER POPULAR PARA EL PROCESO SOCIAL DEL TRABAJO");
$pdf->Text(62, 50, "INSTITUTO VENEZOLANO DE LOS SEGUROS SOCIALES");
$pdf->SetLeftMargin(20.0);
$pdf->SetRightMargin(20.0);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Text(20, 70, "OFICIO:");
$pdf->SetFont('Arial', '', 12);
$pdf->Text(44, 70, $num_control_oficio);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Text(20, 80, "PARA:");
$pdf->SetFont('Arial', 'b', 12);
#$pdf->Text(44,80,strtoupper(utf8_decode($nombre_director)));
$pdf->Text(44, 80, strtoupper(utf8_decode("JACINTO PEREZ BONALDE SANCHEZ")));
$pdf->SetFont('Arial', '', 12);
$pdf->Text(44, 90, utf8_decode($dir_destino_oficio));
$pdf->SetFont('Arial', 'B', 12);
$pdf->Text(20, 100, "DE:");
$pdf->SetFont('Arial', 'b', 12);
$pdf->Text(44, 100, utf8_decode($remitente_oficio));
$pdf->SetFont('Arial', '', 12);
$pdf->Text(44, 110, utf8_decode(end(explode("-", $dir_origen_oficio))));
$pdf->SetFont('Arial', 'B', 12);
$pdf->Text(20, 120, "FECHA:");
$pdf->SetFont('Arial', '', 12);
$pdf->Text(44, 120, $fecha_crea_oficio);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Text(20, 130, "ASUNTO:");
$pdf->SetFont('Arial', '', 12);
$pdf->Text(44, 130, utf8_decode($asunto_oficio));
$pdf->SetXY(10, 140);
$pdf->SetFont('Arial', '', 10);
$pdf->SetTopMargin(2.0);
$pdf->SetLeftMargin(20.0);
$pdf->SetRightMargin(20.0);
$pdf->MultiCell(0, 7, utf8_decode($descripcion_oficio));
$pdf->SetFont('Arial', 'b', 10);
$pdf->Text(93, 245, "Atentamente");
$pdf->Line(50, 264, 160, 264);
#$pdf->Image($this->config->base_url().'fronted/img/FIRMADIGITAL.png',52,230,115);
$pdf->SetFont('Arial', '', 10);
$pdf->Text(75, 268, utf8_decode($remitente_oficio));
$pdf->SetFont('Arial', '', 10);
$pdf->Text(88, 272, utf8_decode("Director general"));
$pdf->SetFont('Arial', '', 10);
$pdf->Text(76, 276, utf8_decode("Según resolución:" . $resolucion_director));
$pdf->Output('oficio_' . $num_control_oficio, 'I');
#tabla
/*
$cabecera=array('Usuario', 'Total asignados', 'Ejecutados');
$pdf->SetXY(10,30); //Seleccionamos posición
$pdf->SetFont('Arial','B',10); //Fuente, Negrita, tamaño
foreach($cabecera as $columna){
//Parámetro con valor 2, cabecera vertical
$pdf->Cell(50,7, utf8_decode($columna),1, 0,'L');
}
$pdf->SetXY(10,31);
$pdf->Ln();//Salto de línea para generar otra fila
$pdf->Ln();//Salto de línea para generar otra fila
foreach($cabecera as $fila){
//Atención!! el parámetro valor 0, hace que sea horizontal
$pdf->Cell(50,7, utf8_decode($fila),1, 0 , '' );
}
*/
#llave clase.
}
示例10: generatePDF
/**
* generatePDF - Génère un fichier PDF à partir des données d'évaluation d'un service
*
* @category : eval_ccpc_functions
* @param array $data Données d'évaluation récupérées à partir de la fonction {@link getEvaluationCCPCFullData()}
* @param boolean $comment TRUE si on incut les commentaire, FALSE si on ne les inclut pas
* @param boolean $commentMSG TRUE si on incut un message concernant la CSG, FALSE si on ne l'inclut pas
* @return array Array contenant les informations du fichier généré
*
* @Author Ali Bellamine
*
* Contenu de l'array retourné :<br>
* ['pdfPath'] => (string) Chemin local vers le fichier généré<br>
* ['pdfURI'] => (string) URI pointant vers le fichier généré
*
*/
function generatePDF($data, $comment = FALSE, $commentMSG = FALSE)
{
// Accès à la BDD
global $db;
// Array contenant les résultats
$output = array();
// On vérifie l'existence des données
if (isset($data) && count($data) > 0) {
/*
Mise en cache
*/
// Calcul du md5
$hashdata = $data;
$hashdata['optionsPDF'] = array('comment' => $comment, 'commentMSG' => $commentMSG);
$hash = md5(json_encode($hashdata));
$pdfPath = PLUGIN_PATH . 'cache/' . $hash . '.pdf';
$pdfPathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.pdf';
if (is_file($pdfPath)) {
$output['pdfPath'] = $pdfPath;
$output['pdfURI'] = $pdfPathURI;
return $output;
} else {
// On charge la librairie
require_once PLUGIN_PATH . 'core/fpdf17/fpdf.php';
// On charge le fichier XML
if (is_file(PLUGIN_PATH . 'formulaire.xml')) {
$form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml');
}
// Promotion
if (count($data['service']['promotion']) > 1) {
$promotion = false;
} else {
foreach ($data['service']['promotion'] as $promotionData) {
$promotion = $promotionData['id'];
}
}
try {
ob_end_clean();
} catch (Exception $e) {
}
// On crée le PDF
$A4Height = 842;
$A4Width = 595;
$titleSize = 15;
$textSize = 11;
$pdf = new FPDF('L', 'pt', 'A4');
$pdf->SetTopMargin(10);
$pdf->SetLeftMargin(15);
$pdf->SetAutoPageBreak(TRUE, 10);
/**
Page contenant le résumé des données d'évaluation
**/
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', $titleSize);
// On affiche le titre
$pdf->SetFillColor(70, 70, 242);
$pdf->SetTextColor(255, 255, 255);
$pdf->SetX(floor(0.1 * $A4Height));
$pdf->Cell(floor(0.8 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_TITLE), 'LRTB', 0, 'C', TRUE);
// Première ligne
$pdf->Ln(2 * $titleSize);
$pdf->SetFont('Arial', '', $textSize);
// On affiche les informations concernant le service
// Récupération des données
$textToDisplay = LANG_FORM_CCPC_FILTER_SERVICE_TITLE . ' : ' . $data['service']['FullName'] . PHP_EOL . LANG_FORM_CCPC_PDF_STAGEPERIODE . ' : ' . date('d/m/Y', $data['service']['date']['min']) . ' - ' . date('d/m/Y', $data['service']['date']['max']);
// Nombre d'étudiants par promotion
$nbEtudiantsService = array();
$sql = 'SELECT p.nom promotion, COUNT( ae.userId ) nombre
FROM `affectationexterne` ae
INNER JOIN user u ON u.id = ae.userId
INNER JOIN promotion p ON p.id = u.promotion
WHERE `dateDebut` >= "' . TimestampToDatetime($data['service']['date']['min']) . '" AND `dateFin` <= "' . TimestampToDatetime($data['service']['date']['max']) . '" AND service = ' . $data['service']['id'] . '
GROUP BY u.promotion';
$res = $db->query($sql);
while ($res_f = $res->fetch()) {
$nbEtudiantsService[$res_f['promotion']] = $res_f['nombre'];
}
$firstLoop = true;
if (count($nbEtudiantsService) > 0) {
$textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTPROMOTION . ' : ';
foreach ($nbEtudiantsService as $promotionNom => $promotionNombre) {
if (!$firstLoop) {
$textToDisplay .= ', ';
} else {
//.........这里部分代码省略.........
示例11: generatePDF
/**
* generatePDF - Génère un fichier PDF à partir des données d'évaluation d'un service
*
* @category : eval_ccpc_functions
* @param array $data Données d'évaluation récupérées à partir de la fonction {@link getEvaluationCCPCFullData()}
* @param boolean $comment TRUE si on incut les commentaire, FALSE si on ne les inclut pas
* @param boolean $commentMSG TRUE si on incut un message concernant la CSG, FALSE si on ne l'inclut pas
* @return array Array contenant les informations du fichier généré
*
* @Author Ali Bellamine
*
* Contenu de l'array retourné :<br>
* ['pdfPath'] => (string) Chemin local vers le fichier généré<br>
* ['pdfURI'] => (string) URI pointant vers le fichier généré
*
*/
function generatePDF($data, $comment = FALSE, $commentMSG = FALSE)
{
// Array contenant les résultats
$output = array();
// On vérifie l'existence des données
if (isset($data) && count($data) > 0) {
/*
Mise en cache
*/
// Calcul du md5
$hashdata = $data;
$hashdata['optionsPDF'] = array('comment' => $comment, 'commentMSG' => $commentMSG);
$hash = md5(json_encode($hashdata));
$pdfPath = PLUGIN_PATH . 'cache/' . $hash . '.pdf';
$pdfPathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.pdf';
if (is_file($pdfPath)) {
$output['pdfPath'] = $pdfPath;
$output['pdfURI'] = $pdfPathURI;
return $output;
} else {
// On charge la librairie
require_once PLUGIN_PATH . 'core/fpdf17/fpdf.php';
// On charge le fichier XML
if (is_file(PLUGIN_PATH . 'formulaire.xml')) {
$form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml');
}
// Promotion
if (count($data['service']['promotion']) > 1) {
$promotion = false;
} else {
foreach ($data['service']['promotion'] as $promotionData) {
$promotion = $promotionData['id'];
}
}
ob_end_clean();
// On crée le PDF
$A4Height = 842;
$A4Width = 595;
$titleSize = 15;
$textSize = 11;
$pdf = new FPDF('L', 'pt', 'A4');
$pdf->SetTopMargin(10);
$pdf->SetLeftMargin(15);
$pdf->SetAutoPageBreak(TRUE, 10);
/**
Page contenant le résumé des données d'évaluation
**/
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', $titleSize);
// On affiche le titre
$pdf->SetFillColor(70, 70, 242);
$pdf->SetTextColor(255, 255, 255);
$pdf->SetX(floor(0.1 * $A4Height));
$pdf->Cell(floor(0.8 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_TITLE), 'LRTB', 0, 'C', TRUE);
// Première ligne
$pdf->Ln(2 * $titleSize);
$pdf->SetFont('Arial', '', $textSize);
// On affiche les informations concernant le service
// Récupération des données
$textToDisplay = LANG_FORM_CCPC_FILTER_SERVICE_TITLE . ' : ' . $data['service']['FullName'] . PHP_EOL . LANG_FORM_CCPC_PDF_STAGEPERIODE . ' : ' . date('d/m/Y', $data['service']['date']['min']) . ' - ' . date('d/m/Y', $data['service']['date']['max']) . PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTPROMOTION . ' : ';
$firstLoop = true;
foreach ($data['service']['promotion'] as $promotionData) {
if (!$firstLoop) {
$textToDisplay .= ', ';
} else {
$firstLoop = FALSE;
}
$textToDisplay .= $promotionData['nom'] . ' (' . $promotionData['nb'] . ')';
}
$textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTNB . ' : ' . $data['service']['nbEvaluation'] . PHP_EOL . LANG_FORM_CCPC_PDF_EVALUATIONNB . ' : ' . $data['nb'];
$textToDisplay = utf8_decode($textToDisplay);
// Affichage
$pdf->SetFillColor(231, 231, 231);
$pdf->SetTextColor(0, 0, 0);
$pdf->MultiCell(floor(0.35 * $A4Height), $textSize + 5, $textToDisplay, 'LRTB', 'L', TRUE);
// On affiche les graphiques : mainGraphPDF
// Récupération des données
// Liste des graphiques à afficher
$input = $form->xpath('categorie/input[@mainPDFGraph="1"]');
$nbGraph = count($input);
// Nombre de graphiques à intégrer
// On génère $tempData, contenant les données utilisées pour génération du png
foreach ($input as $select) {
if ($select['type'] == 'select') {
//.........这里部分代码省略.........
示例12: generateJobOrderReportPDF
//.........这里部分代码省略.........
/* PDF Font Face. */
// FIXME: Customizable.
$fontFace = 'Arial';
$pdf = new FPDF();
$pdf->AddPage();
if (!eval(Hooks::get('REPORTS_CUSTOMIZE_JO_REPORT_PRE'))) {
return;
}
if ($isASP && $unixName == 'cognizo') {
/* TODO: MAKE THIS CUSTOMIZABLE FOR EVERYONE. */
$pdf->SetFont($fontFace, 'B', 10);
$pdf->Image('images/cognizo-logo.jpg', 130, 10, 59, 20);
$pdf->SetXY(129, 27);
$pdf->Write(5, 'Information Technology Consulting');
}
$pdf->SetXY(25, 35);
$pdf->SetFont($fontFace, 'BU', 14);
$pdf->Write(5, "Recruiting Summary Report\n");
$pdf->SetFont($fontFace, '', 10);
$pdf->SetX(25);
$pdf->Write(5, DateUtility::getAdjustedDate('l, F d, Y') . "\n\n\n");
$pdf->SetFont($fontFace, 'B', 10);
$pdf->SetX(25);
$pdf->Write(5, 'Company: ' . $companyName . "\n");
$pdf->SetFont($fontFace, '', 10);
$pdf->SetX(25);
$pdf->Write(5, 'Position: ' . $jobOrderName . "\n\n");
$pdf->SetFont($fontFace, '', 10);
$pdf->SetX(25);
$pdf->Write(5, 'Period: ' . $periodLine . "\n\n");
$pdf->SetFont($fontFace, '', 10);
$pdf->SetX(25);
$pdf->Write(5, 'Account Manager: ' . $accountManager . "\n");
$pdf->SetFont($fontFace, '', 10);
$pdf->SetX(25);
$pdf->Write(5, 'Recruiter: ' . $recruiter . "\n");
/* Note that the server is not logged in when getting this file from
* itself.
*/
// FIXME: Pass session cookie in URL? Use cURL and send a cookie? I
// really don't like this... There has to be a way.
// FIXME: "could not make seekable" - http://demo.catsone.net/index.php?m=graphs&a=jobOrderReportGraph&data=%2C%2C%2C
// in /usr/local/www/catsone.net/data/lib/fpdf/fpdf.php on line 1500
$URI = CATSUtility::getAbsoluteURI(CATSUtility::getIndexName() . '?m=graphs&a=jobOrderReportGraph&data=' . urlencode(implode(',', $dataSet)));
$pdf->Image($URI, 70, 95, 80, 80, 'jpg');
$pdf->SetXY(25, 180);
$pdf->SetFont($fontFace, '', 10);
$pdf->Write(5, 'Total Candidates ');
$pdf->SetTextColor(255, 0, 0);
$pdf->Write(5, 'Screened');
$pdf->SetTextColor(0, 0, 0);
$pdf->Write(5, ' by ' . $siteName . ": \n\n");
$pdf->SetX(25);
$pdf->SetFont($fontFace, '', 10);
$pdf->Write(5, 'Total Candidates ');
$pdf->SetTextColor(0, 125, 0);
$pdf->Write(5, 'Submitted');
$pdf->SetTextColor(0, 0, 0);
$pdf->Write(5, ' to ' . $companyName . ": \n\n");
$pdf->SetX(25);
$pdf->SetFont($fontFace, '', 10);
$pdf->Write(5, 'Total Candidates ');
$pdf->SetTextColor(0, 0, 255);
$pdf->Write(5, 'Interviewed');
$pdf->SetTextColor(0, 0, 0);
$pdf->Write(5, ' by ' . $companyName . ": \n\n");
$pdf->SetX(25);
$pdf->SetFont($fontFace, '', 10);
$pdf->Write(5, 'Total Candidates ');
$pdf->SetTextColor(255, 75, 0);
$pdf->Write(5, 'Placed');
$pdf->SetTextColor(0, 0, 0);
$pdf->Write(5, ' at ' . $companyName . ": \n\n\n");
if ($notes != '') {
$pdf->SetX(25);
$pdf->SetFont($fontFace, '', 10);
$pdf->Write(5, "Notes:\n");
$len = strlen($notes);
$maxChars = 70;
$pdf->SetLeftMargin(25);
$pdf->SetRightMargin(25);
$pdf->SetX(25);
$pdf->Write(5, $notes . "\n");
}
$pdf->SetXY(165, 180);
$pdf->SetFont($fontFace, 'B', 10);
$pdf->Write(5, $dataSet[0] . "\n\n");
$pdf->SetX(165);
$pdf->Write(5, $dataSet[1] . "\n\n");
$pdf->SetX(165);
$pdf->Write(5, $dataSet[2] . "\n\n");
$pdf->SetX(165);
$pdf->Write(5, $dataSet[3] . "\n\n");
$pdf->Rect(3, 6, 204, 285);
if (!eval(Hooks::get('REPORTS_CUSTOMIZE_JO_REPORT_POST'))) {
return;
}
$pdf->Output();
die;
}
示例13: max
$address = create_address($parties[$i]);
// Figure out what the longest line is
$pdf->SetFont("Astrud", "", NAME_SIZE_PTS);
$name_width = $pdf->GetStringWidth($name_string);
$pdf->SetFont("ufonts.com_century-gothic", "", ADDR_SIZE_PTS);
$max_addr_width = $pdf->GetStringWidth($address[0]);
for ($j = 1; $j < count($address); ++$j) {
$addr_line_width = $pdf->GetStringWidth($address[$j]);
if ($addr_line_width > $max_addr_width) {
$max_addr_width = $addr_line_width;
}
}
$max_line_width = max($name_width, $max_addr_width);
// Center the longest line, and make everything else left justified to that
$left_x = $start_x + $col * ($x_size + $row_sep) + ($x_size - $max_line_width) / 2;
$pdf->SetLeftMargin($left_x);
// Draw the name line
$pdf->SetFont("Astrud", "", NAME_SIZE_PTS);
//$name_width = $pdf->GetStringWidth($name_string);
//$name_x = $start_x + ($col * ($x_size + $row_sep)) + (($x_size - $name_width) / 2);
$name_y = $start_y + $row * $y_size + TOP_MARGIN_IN;
//$pdf->setXY($name_x, $name_y);
$pdf->setXY($left_x, $name_y);
$pdf->write($name_height, $name_string);
// Draw the address lines
$pdf->SetFont("ufonts.com_century-gothic", "", ADDR_SIZE_PTS);
//$address = create_address($parties[$i]);
// Determine the max address line width
/*
$max_addr_width = $pdf->GetStringWidth($address[0]);
for ($j = 1; $j < count($address); ++$j) {
示例14: makepdf
public function makepdf()
{
global $user;
// Get required files.
require_once 'others/fpdf/fpdf.php';
// Set some document variables
$author = "eduCloud";
$x = 35;
$text = <<<EOT
Hello
EOT;
// Create fpdf object
$pdf = new FPDF('P', 'pt', 'Letter');
// Set base font to start
$pdf->SetFont('Arial', 'B', 16);
// Add a new page to the document
$pdf->addPage();
$pdf->setLeftMargin($x);
//page border
$pdf->Line(35, 30, 35, 750);
$pdf->Line(35, 30, 575, 30);
$pdf->Line(575, 30, 575, 750);
$pdf->Line(575, 750, 35, 750);
//end of page border
// Set the x,y coordinates of the cursor
$pdf->SetXY($x + 20, 40);
// Write 'Simple PDF' with a line height of 1 at the current position
$pdf->Write(25, 'Employee Details');
$pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/cloud/images/school_logo.jpg', 500, 35, 50, 50, 'JPG');
// Reset the font
// Reset font, color, and coordinates
$pdf->SetFont('Arial', '', 12);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetLeftMargin($x + 50);
$pdf->setXY($x + 50, 90);
global $objPDO;
require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/teacher_class.php';
$record = new Teacher($objPDO);
if ($user->checkAdmin()) {
$eid = $_GET['uid'];
} else {
$student = new Student($objPDO, $user->getuserId());
$eid = $student->getID();
}
$record->loadByUserId($eid);
// Write out a long text blurb.
//$array=$record->getAsArray();
//$x=0;
/* TEMPLATE 1 DESIGN*/
$pdf->SetFont('Arial', '', 8);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, 'Employee Id (reference) : ' . $record->getTeacherId(), 0, 1, 'L', true);
$pdf->SetFont('Arial', '', 12);
$pdf->setFillColor(50, 50, 50);
$pdf->setTextColor(255, 255, 255);
$pdf->cell(450, 20, 'Employee Details', 0, 1, 'C', true);
$pdf->setTextColor(0, 0, 0);
$pdf->setFillColor(221, 221, 221);
$pdf->cell(200, 20, 'Employee Name', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getName(), 0, 1, 'C', true);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, 'Qualification', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getQualification(), 0, 1, 'C', true);
require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/subject_class.php';
$subject_id = new Subject($objPDO);
$subject_id->setID($record->getSubjectId());
$pdf->setFillColor(221, 221, 221);
$pdf->cell(200, 20, 'Subject', 0, 0, 'C', true);
$pdf->cell(250, 20, $subject_id->getName(), 0, 1, 'C', true);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, 'Date Of Birth', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getDateOfBirth(), 0, 1, 'C', true);
$pdf->setFillColor(221, 221, 221);
$pdf->cell(200, 20, 'Gender', 0, 0, 'C', true);
$pdf->cell(250, 20, ucfirst($record->getGender()), 0, 1, 'C', true);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, 'Blood Group', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getBloodGroup(), 0, 1, 'C', true);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, '', 0, 0, 'C', true);
$pdf->cell(250, 20, '', 0, 1, 'C', true);
$pdf->setFillColor(50, 50, 50);
$pdf->setTextColor(255, 255, 255);
$pdf->cell(450, 20, 'Contact Details', 0, 1, 'C', true);
$pdf->setTextColor(0, 0, 0);
$pdf->setFillColor(221, 221, 221);
$pdf->cell(200, 20, 'Correspondence Address', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getCorrespondenceAddressLine1(), 0, 1, 'C', true);
$pdf->cell(200, 20, '', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getCorrespondenceAddressLine2(), 0, 1, 'C', true);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, 'City', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getCorrespondenceCity(), 0, 1, 'C', true);
$pdf->setFillColor(221, 221, 221);
$pdf->cell(200, 20, 'State', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getCorrespondenceState(), 0, 1, 'C', true);
$pdf->setFillColor(255, 255, 255);
$pdf->cell(200, 20, 'Pincode', 0, 0, 'C', true);
$pdf->cell(250, 20, $record->getCorrespondencePincode(), 0, 1, 'C', true);
$pdf->setFillColor(221, 221, 221);
//.........这里部分代码省略.........
示例15: drawPDF
public function drawPDF()
{
$pdf = new \FPDF('P', 'mm', 'Letter');
$width = 52;
// tag width in mm
$height = 31;
// tag height in mm
$left = 5.5;
// left margin
$top = 15;
// top margin
$pdf->SetTopMargin($top);
//Set top margin of the page
$pdf->SetLeftMargin($left);
//Set left margin of the page
$pdf->SetRightMargin($left);
//Set the right margin of the page
$pdf->SetAutoPageBreak(False);
// manage page breaks yourself
$data = $this->loadItems();
$num = 0;
// count tags
$x = $left;
$y = $top;
foreach ($data as $item) {
// extract & format data
$price = $item['normal_price'];
$desc = strtoupper(substr($item['posDescription'], 0, 27));
$brand = strtoupper(substr($item['brand'], 0, 13));
$pak = $item['units'];
$size = $item['units'] . "-" . $item['size'];
$sku = $item['sku'];
$ppu = $item['pricePerUnit'];
$vendor = substr($item['vendor'], 0, 7);
$upc = $item['upc'];
if ($num % 32 == 0) {
$pdf->AddPage();
$x = $left;
$y = $top;
} else {
if ($num % 4 == 0) {
$x = $left;
$y += $height;
}
}
$args = array('height' => 7, 'valign' => 'T', 'align' => 'L', 'suffix' => date(' n/j/y'), 'fontsize' => 8, 'font' => $this->font);
$pdf = $this->drawBarcode($upc, $pdf, $x + 7, $y + 4, $args);
$pdf->SetFont($this->font, '', 8);
$pdf->SetXY($x, $y + 12);
$pdf->Cell($width, 4, $desc, 0, 1, 'L');
$pdf->SetX($x);
$pdf->Cell($width, 4, $brand, 0, 1, 'L');
$pdf->SetX($x);
$pdf->Cell($width, 4, $size, 0, 1, 'L');
$pdf->SetX($x);
$pdf->Cell($width, 4, $sku . ' ' . $vendor, 0, 0, 'L');
if (strstr($ppu, '/') && $ppu[strlen($ppu) - 1] != '/') {
$pdf->SetX($x);
$pdf->Cell($width - 5, 4, $ppu, 0, 0, 'R');
}
$pdf->SetXY($x, $y + 16);
$pdf->SetFont($this->font, 'B', 24);
//change font size
$pdf->Cell($width - 5, 8, $price, 0, 0, 'R');
// move right by tag width
$x += $width;
$num++;
}
$pdf->Output('Tags4x8P.pdf', 'I');
}