protected function ConvertToPdf::generator in PDF using mPDF 8.2
Same name and namespace in other branches
- 8 src/Conversion/ConvertToPdf.php \Drupal\pdf_using_mpdf\Conversion\ConvertToPdf::generator()
Parameters
$html: contents of the template already with the node data.
1 call to ConvertToPdf::generator()
- ConvertToPdf::convert in src/
Conversion/ ConvertToPdf.php - Point of call to instantiate the mPDF library and call the generator functions for creating a PDF file.
File
- src/
Conversion/ ConvertToPdf.php, line 101
Class
Namespace
Drupal\pdf_using_mpdf\ConversionCode
protected function generator($html) {
$styles = $this
->importStyles();
$this
->replaceAllSettingsTokens();
try {
$this->mpdf = new Mpdf($this->settings);
$this
->setHeader();
$this
->applyProperties();
$this
->setFooter();
// Apply custom cascading styles.
if (!empty($styles)) {
$this->mpdf
->WriteHTML($styles, \Mpdf\HTMLParserMode::HEADER_CSS);
}
$this->mpdf
->WriteHTML($html, \Mpdf\HTMLParserMode::HTML_BODY);
$this
->output();
} catch (MpdfException $e) {
$message = $e
->getMessage();
$this->logger
->get('pdf_using_mpdf')
->critical('Error:' . $message);
return;
}
}