You are here

public function ConvertToPdf::convert in PDF using mPDF 8.2

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

Point of call to instantiate the mPDF library and call the generator functions for creating a PDF file.

Parameters

string $html: The html that will be converted into PDF content.

array $settings: Optional. Additional mPDF settings to add and overwrite existing ones Overwriting mPDF settings is useful when a different PDF settings are desired for different files per use case

array $options: An optional array containing usually the context variables used for token replacement

Overrides ConvertToPdfInterface::convert

File

src/Conversion/ConvertToPdf.php, line 82

Class

ConvertToPdf

Namespace

Drupal\pdf_using_mpdf\Conversion

Code

public function convert($html, $settings = [], $options = []) {
  if (empty($html)) {
    $this->logger
      ->get('pdf_using_mpdf')
      ->error(t('There was an error generating PDF - No HTML content provided.'));
    return;
  }

  // Overwrite settings - altered via hook_mpdf_settings_alter()
  $this->settings = array_merge($this->settings, $this
    ->getDefaultConfig(), $settings);
  $this->context = $options;
  $this
    ->generator($html);
}