本文整理汇总了PHP中FPDI::setXY方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::setXY方法的具体用法?PHP FPDI::setXY怎么用?PHP FPDI::setXY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::setXY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render a certificate
*
* @param object $user User
* @param string $path Path to store rendered file to
* @return boolean True on success, false on error
*/
public function render($user = null, $path = null)
{
if (!$user) {
$user = \User::getRoot();
}
if (!class_exists('\\Components\\Courses\\Models\\Course')) {
require_once __DIR__ . DS . 'course.php';
}
$course = Course::getInstance($this->get('course_id'));
require_once PATH_CORE . DS . 'libraries' . DS . 'fpdf16' . DS . 'fpdf.php';
require_once PATH_CORE . DS . 'libraries' . DS . 'fpdi' . DS . 'fpdi.php';
// Get the pdf and draw on top of it
$pdf = new \FPDI();
$pageCount = $pdf->setSourceFile($this->path('system') . DS . 'certificate.pdf');
$tplIdx = $pdf->importPage(1);
$size = $pdf->getTemplateSize($tplIdx);
$pdf->AddPage('L', array($size['h'], $size['w']));
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
$pdf->SetFillColor(0, 0, 0);
foreach ($this->properties()->elements as $element) {
// Convert pixel values to percents
$element->x = $element->x / $this->properties()->width;
$element->y = $element->y / $this->properties()->height;
$element->w = $element->w / $this->properties()->width;
$element->h = $element->h / $this->properties()->height;
$val = '';
switch ($element->id) {
case 'name':
case 'email':
case 'username':
$val = $user->get($element->id);
break;
case 'course':
$val = $course->get('title');
break;
case 'offering':
$val = $course->offering()->get('title');
break;
case 'section':
$val = $course->offering()->section()->get('title');
break;
case 'date':
$val = \Date::of('now')->format(Lang::txt('d M Y'));
break;
}
$pdf->SetFont('Arial', '', 30);
//($element->h * $size['h']));
$pdf->setXY($element->x * $size['w'], $element->y * $size['h']);
// - ($element->h * $size['h'])
$pdf->Cell($element->w * $size['w'], $element->h * $size['h'], $val, '', 1, 'C');
}
if (!$path) {
$pdf->Output();
die;
}
$pdf->Output($path, 'F');
return true;
}
示例2: generatePDF
//.........这里部分代码省略.........
$pdf->SetXY(10, 32 + $logo_height);
if (!empty($societe->tva_intracommunautaire)) {
$pdf->Cell(60, 4, utf8_decode(_("VAT code")) . " " . $societe->raison_sociale . " : {$societe->tva_intracommunautaire}\n");
}
if (!empty($facture->vat_number)) {
$pdf->Write(5, utf8_decode(_("Your VAT code")) . " : {$facture->vat_number}\n");
}
$pdf->Write(5, $facture->ref_contrat . "\n");
$pdf->Write(5, wordwrap($facture->extra_top, 70));
// Lignes de facturation
$pdf->SetLineWidth(0.1);
$pdf->SetXY(10, 80);
$pdf->SetFont('Arial', 'B', '10');
$pdf->Cell(110, 6, utf8_decode(_("Designation")), 1);
$pdf->Cell(20, 6, utf8_decode(_("Quantity")), 1, 0, "C");
$pdf->Cell(30, 6, utf8_decode(_("VAT excl.")), 1, 0, "C");
$pdf->Cell(30, 6, utf8_decode(_("Total")), 1, 0, "C");
$pdf->Ln();
$total_ht = 0;
foreach ($facture->lignes as $ligne) {
foreach ($ligne as $n => $v) {
$ligne->{$n} = preg_replace("/€/", "EUROSYMBOL", $ligne->{$n});
$ligne->{$n} = utf8_decode($ligne->{$n});
$ligne->{$n} = preg_replace("/EUROSYMBOL/", chr(128), $ligne->{$n});
}
setlocale(LC_TIME, "fr_FR.UTF8");
// Replace dates like YYYY-MM-DD with nice expanded date
$ligne->description = preg_replace_callback('/\\d{4}-\\d{2}-\\d{2}/', create_function('$matches', 'return utf8_decode(strftime("%e %B %Y", strtotime($matches[0])));'), $ligne->description);
$y_start = $pdf->getY();
$pdf->SetFont('Arial', '', '10');
$pdf->MultiCell(110, 6, $ligne->description, "LR", 'L');
$x = $pdf->getX();
$y = $pdf->getY();
$pdf->setXY(120, $y_start);
$pdf->Cell(20, 6, $ligne->qtt, "LR", 0, "C");
$pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $ligne->prix_ht)), "LR", 0, "R");
$pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $ligne->prix_ht * $ligne->qtt)), "LR", 0, "R");
$pdf->setXY(120, $y_start);
$pdf->Cell(20, $y - $y_start, '', "LR", 0, "C");
$pdf->Cell(30, $y - $y_start, '', "LR", 0, "R");
$pdf->Cell(30, $y - $y_start, '', "LR", 0, "R");
$total_ht += $ligne->prix_ht * $ligne->qtt;
$pdf->Ln();
$pdf->Cell(110, 2, "", "LR");
$pdf->Cell(20, 2, "", "LR");
$pdf->Cell(30, 2, "", "LR");
$pdf->Cell(30, 2, "", "LR");
$pdf->Ln();
}
$y_fin = $pdf->getY();
if ($y < 190) {
$pdf->Cell(110, 190 - $y, "", "LRB", 0, "C");
$pdf->Cell(20, 190 - $y, "", "LRB", 0, "C");
$pdf->Cell(30, 190 - $y, "", "LRB", 0, "C");
$pdf->Cell(30, 190 - $y, "", "LRB", 0, "C");
$pdf->Ln();
}
// Total HT
$txt_type_paiement = $facture->type_paiement;
if (preg_match('/eption de cette facture/', $txt_type_paiement) and $facture->language != 'fr_FR') {
$txt_type_paiement = _('upon receipt of invoice');
}
$pdf->SetFont('Arial', '', '11');
$pdf->Cell(130, 6, utf8_decode(_("Payment")) . " : " . $txt_type_paiement);
$pdf->Cell(30, 6, utf8_decode(_("Subtotal")), "", 0, "R");
$pdf->Cell(30, 6, preg_replace("/\\./", ",", sprintf("%.2f" . EURO, $total_ht)), "", 0, "R");