You are here

public function views_plugin_display_entity_print_views_pdf::execute in Entity Print 7

The display page handler returns a normal view, but it also does a drupal_set_title for the page, and does a views_set_page_view on the view.

Overrides views_plugin_display_page::execute

File

modules/entity_print_views/includes/views/views_plugin_display_entity_print_views_pdf.inc, line 13
The PDF display handler.

Class

views_plugin_display_entity_print_views_pdf
@file The PDF display handler.

Code

public function execute() {
  $library = libraries_load('phpwkhtmltopdf');
  if (!empty($library['loaded'])) {
    $pdf = new WkHtmlToPdf(array(
      'binary' => variable_get('entity_print_wkhtmltopdf', '/usr/local/bin/wkhtmltopdf'),
    ));
    $html = $this->view
      ->render();

    // Inject some generic CSS across all templates.
    if (variable_get('entity_print_default_css', TRUE)) {
      entity_print_add_css(drupal_get_path('module', 'entity_print') . '/css/entity-print.css');
    }

    // Wrap the output with the appropriate template.
    $html = theme('entity_print_views__' . $this->view->name, array(
      'view_html' => $html,
      'view' => $this->view,
      'entity_print_css' => _entity_print_views_get_css($this->view),
    ));

    // Add the page of HTML.
    $pdf
      ->addPage($html);

    // Allow other modules to alter the generated PDF object.
    drupal_alter('entity_print_pdf_views', $pdf, $this->view);

    // Keep backwards compatability.
    drupal_alter('entity_print_pdf_view', $pdf, $this->view);
    if (!$pdf
      ->send()) {
      return $pdf
        ->getError();
    }
  }
  else {
    return $library['error message'];
  }
}