protected function PdfTemplate::renderRow in Views PDF 6
Same name and namespace in other branches
- 7 views_pdf_template.php \PdfTemplate::renderRow()
- 7.2 views_pdf_template.php \PdfTemplate::renderRow()
2 calls to PdfTemplate::renderRow()
- PdfTemplate::drawContent in ./views_pdf_template.php
- This method draws a field on the PDF.
- PdfTemplate::drawTable in ./views_pdf_template.php
- This method draws a table on the PDF.
File
- ./views_pdf_template.php, line 352
- 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
protected function renderRow($x, $y, $row, $options, &$view = NULL, $key = NULL) {
$pageDim = $this
->getPageDimensions();
if (is_object($view) && $key != NULL && is_object($view->field[$key])) {
$content = $view->field[$key]
->theme($row);
}
elseif (is_string($row)) {
$content = $row;
}
else {
return;
}
if (!empty($view->field[$key]->options['exclude'])) {
return '';
}
if (!isset($options['text']['hyphenate']) && is_object($view) && is_object($view->display_handler)) {
$options['text']['hyphenate'] = $view->display_handler
->get_option('default_text_hyphenate');
}
if (isset($options['text']['hyphenate']) && $options['text']['hyphenate'] != 'none') {
$patternFile = $options['text']['hyphenate'];
if ($options['text']['hyphenate'] == 'auto' && is_object($row)) {
$nodeLanguage = $row->node_language;
foreach (self::getAvailableHyphenatePatterns() as $file => $pattern) {
if (stristr($pattern, $nodeLanguage) !== FALSE) {
$patternFile = $file;
break;
}
}
}
$patternFile = views_pdf_get_library('tcpdf') . '/hyphenate_patterns/' . $patternFile;
if (file_exists($patternFile)) {
$hyphen_patterns = $this
->getHyphenPatternsFromTEX($patternFile);
$content = str_replace('>', '>', $content);
$content = str_replace('<', '&lt;', $content);
$content = $this
->hyphenateText($content, $hyphen_patterns);
}
}
if (is_object($view) && is_object($view->display_handler)) {
$css_file = $view->display_handler
->get_option('css_file');
}
$font_size = empty($options['text']['font_size']) ? $this->defaultFontSize : $options['text']['font_size'];
$font_family = $options['text']['font_family'] == 'default' || empty($options['text']['font_family']) ? $this->defaultFontFamily : $options['text']['font_family'];
$font_style = is_array($options['text']['font_style']) ? $options['text']['font_style'] : $this->defaultFontStyle;
$textColor = !empty($options['text']['color']) ? $this
->parseColor($options['text']['color']) : $this
->parseColor($this->defaultFontColor);
$w = $options['position']['width'];
$h = $options['position']['height'];
$border = 0;
$align = isset($options['text']['align']) ? $options['text']['align'] : $this->defaultTextAlign;
$fill = 0;
$ln = 1;
$reseth = true;
$stretch = 0;
$ishtml = isset($options['render']['is_html']) ? $options['render']['is_html'] : 1;
$stripHTML = !$ishtml;
$autopadding = true;
$maxh = 0;
$valign = 'T';
$fitcell = false;
eval($options['render']['eval_before']);
if (!empty($css_file) && is_string($css_file) && !$stripHTML && $ishtml && !empty($content)) {
$content = '<link type="text/css" rel="stylesheet" media="all" href="' . $css_file . '" />' . "\n" . $content;
}
$this
->SetTextColorArray($textColor);
$this
->SetFont($font_family, implode('', $font_style), $font_size);
$this->lastWritingPage = $this
->getPage();
if ($stripHTML) {
$content = strip_tags($content);
}
$this
->MultiCell($w, $h, $content, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml, $autopadding, $maxh, $valign, $fitcell);
$this
->SetFont($this->defaultFontFamily, implode('', $this->defaultFontStyle), $this->defaultFontSize);
eval($options['render']['eval_after']);
$this->elements[$key] = array(
'x' => $x,
'y' => $y,
'width' => empty($w) ? $pageDim['wk'] - $this->rMargin - $x : $w,
'height' => $this->y - $y,
'page' => $this->lastWritingPage,
);
$this->lastWritingElement = $key;
}