You are here

public function ConvertToPdf::showPdf in PDF using mPDF 8

Show PDF to the user.

1 call to ConvertToPdf::showPdf()
ConvertToPdf::convert in src/Conversion/ConvertToPdf.php
Converts HTML to PDF.

File

src/Conversion/ConvertToPdf.php, line 259

Class

ConvertToPdf
Class ConvertToPdf.

Namespace

Drupal\pdf_using_mpdf\Conversion

Code

public function showPdf() {
  switch ($this->settings['pdf_save_option']) {
    case 0:
      $this->mpdf
        ->Output($this->filename . '.pdf', Destination::INLINE);
      break;
    case 1:
      $this->mpdf
        ->Output($this->filename . '.pdf', Destination::DOWNLOAD);
      break;
    case 2:
      $folder = \Drupal::service('file_system')
        ->realpath(file_default_scheme() . "://");
      $folder .= '/pdf_using_mpdf';
      $this->mpdf
        ->Output($folder . '/' . $this->filename . '.pdf', Destination::FILE);
      drupal_set_message(t('PDF File <em>@filename</em> has been saved to the server.', [
        '@filename' => $this->filename . '.pdf',
      ]));
      break;
  }
}