public function PdfTemplate::setViewsHeader in Views PDF 7
Same name and namespace in other branches
- 7.2 views_pdf_template.php \PdfTemplate::setViewsHeader()
File
- ./
views_pdf_template.php, line 150 - PDF Class to generate PDFs with native PHP. This class based on FPDF and FPDI.
Class
- PdfTemplate
- The main class to generate the PDF.
Code
public function setViewsHeader($header, $options) {
$this->views_header = $header;
if (!empty($this->views_header)) {
if (isset($options['position'])) {
// Set draw point to the indicated position:
if (empty($options['position']['x'])) {
$options['position']['x'] = 0;
}
if (empty($options['position']['y'])) {
$options['position']['y'] = 0;
}
if (isset($options['position']['last_writing_position']) && $options['position']['last_writing_position']) {
$y = $options['position']['y'] + $this->y;
$x = $options['position']['x'] + $this->x;
}
else {
$y = $options['position']['y'];
$x = $options['position']['x'];
}
$this->lMargin = $x;
}
$page = $this
->getPage();
if ($page == 0) {
$this
->addPage();
$page = $this
->getPage();
}
if (isset($options['position'])) {
$this
->SetXY($x, $y);
}
$this
->setPage($page);
$this
->writeHTML($this->views_header, true, false, false, true);
if (isset($options['position'])) {
$this
->SetX($x);
}
}
}