You are here

protected function ConvertToPdf::generator in PDF using mPDF 8

Same name and namespace in other branches
  1. 8.2 src/Conversion/ConvertToPdf.php \Drupal\pdf_using_mpdf\Conversion\ConvertToPdf::generator()

Generate the PDF file using the Mpdf library.

Parameters

string $html: Contents of the template already with the node data.

Throws

\Mpdf\MpdfException

2 calls to ConvertToPdf::generator()
ConvertToPdf::convert in src/Conversion/ConvertToPdf.php
Converts HTML to PDF.
ConvertToPdf::convertToString in src/Conversion/ConvertToPdf.php
Converts html to PDF and return as a string.

File

src/Conversion/ConvertToPdf.php, line 153

Class

ConvertToPdf
Class ConvertToPdf.

Namespace

Drupal\pdf_using_mpdf\Conversion

Code

protected function generator($html) {
  $styles = $this
    ->importStyles();
  $this
    ->init();
  $this
    ->setHeader();

  // Apply custom cascading styles.
  if (!empty($styles)) {
    $this->mpdf
      ->WriteHTML($styles, 1);
  }
  $this->mpdf
    ->WriteHTML($html, 2);
  $this
    ->applyProperties();
  $this
    ->setFooter();
  $this
    ->setFilename();
}