You are here

public function ConvertToPdf::convertToString in PDF using mPDF 8

Converts html to PDF and return as a string.

Parameters

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

Return value

string Generated output as string or empty.

Overrides ConvertToPdfInterface::convertToString

File

src/Conversion/ConvertToPdf.php, line 126

Class

ConvertToPdf
Class ConvertToPdf.

Namespace

Drupal\pdf_using_mpdf\Conversion

Code

public function convertToString($html) {
  $this->settings = $this
    ->getConfigValues();
  if (empty($html)) {
    drupal_get_messages('error');
    drupal_set_message(t('No content. PDF cannot be generated for this path.'), 'error');
    return;
  }
  $this
    ->generator($html);
  return $this->mpdf
    ->Output('', Destination::STRING_RETURN);
}