You are here

public function PhpWkhtmlToPdf::send in Entity Print 8

Send the PDF contents to the browser.

Parameters

$filename: (optional) The filename if we want to force the browser to download.

Throws

\Drupal\entity_print\PdfEngineException Thrown when PDF generation fails.

Overrides PdfEngineInterface::send

File

src/Plugin/EntityPrint/PdfEngine/PhpWkhtmlToPdf.php, line 81

Class

PhpWkhtmlToPdf
@PdfEngine( id = "phpwkhtmltopdf", label = @Translation("Php Wkhtmltopdf") )

Namespace

Drupal\entity_print\Plugin\EntityPrint\PdfEngine

Code

public function send($filename = NULL) {

  // If the filename received here is NULL, force open in the browser
  // otherwise attempt to have it downloaded.
  if (!$this->pdf
    ->send($filename, (bool) $filename)) {
    throw new PdfEngineException(sprintf('Failed to generate PDF: %s', $this->pdf
      ->getError()));
  }
}