You are here

function Fields::render in Views PDF 8

Renders the rows.

File

src/Plugin/views/row/Fields.php, line 23
Contains \Drupal\views_pdf\Plugin\views\row\Fields.

Class

Fields
This class contains all the functionality of the field PDF style.

Code

function render($row) {
  $options = $this
    ->option_definition();

  // Header of a record.
  $path = $this->view->pdf
    ->getTemplatePath($this->options['leading_template']);
  $this->view->pdf
    ->addPdfDocument($path);

  // Set row page template.
  $path = $this->view->pdf
    ->getTemplatePath($this->options['template'], $row, $this->view);
  $this->view->pdf
    ->setDefaultPageTemplate($path, 'row', 'row');

  // Due of limitations of field renderer, we invoke them
  // here and not in the field render function.
  foreach ($this->view->field as $id => $field) {
    if (isset($this->options['formats'][$id])) {
      $options = $this->options['formats'][$id];
    }
    else {
      $options = array();
    }
    $this->view->pdf
      ->drawContent($row, $options, $this->view, $id);

    // Set or update header / footer options per row
    // this ensures that we write the last record for each page
    // in the cache.
    $this->view->pdf
      ->setHeaderFooter($row, $this->options, $this->view);
  }

  // Footer of a record.
  $path = $this->view->pdf
    ->getTemplatePath($this->options['succeed_template']);
  $this->view->pdf
    ->addPdfDocument($path);

  // Reset the row page number.
  $this->view->pdf
    ->resetRowPageNumber();
}