You are here

function tcpdf_example_default_header in TCPDF 8

Same name and namespace in other branches
  1. 7 tcpdf_example/tcpdf_example.pages.inc \tcpdf_example_default_header()

Callback for generating the header. This function acts like if it overridded the Header() function of tcpdf class except the tcpdf instance is not $this but a parameter.

Parameters

type $tcpdf TCPDFDrupal instance. It can be used as $this in the: Header() function of a siebling of TCPDF.

1 string reference to 'tcpdf_example_default_header'
TcpPdfExampleController::generateSimplePdf in tcpdf_example/src/Controller/TcpPdfExampleController.php
Generates a pdf file using TCPDF module.

File

tcpdf_example/tcpdf_example.module, line 30
Provide examples of using the TCPDF module.

Code

function tcpdf_example_default_header(&$tcpdf, $context) {
  global $base_url;

  // $args contains passed variable...
  $default_theme = \Drupal::config('system.theme')
    ->get('default');
  if ($default_theme) {
    $theme_settings = \Drupal::config($default_theme . '.settings')
      ->get();
    if (isset($theme_settings['logo']['path']) && file_exists($theme_settings['logo']['path'])) {
      $tcpdf
        ->Image(\Drupal::service('file_system')
        ->realpath($theme_settings['logo']['path']), 10, 10, 30, 30, '', $base_url, '', TRUE, 150, '', FALSE, FALSE, 0, FALSE, FALSE, FALSE);
    }
    $tcpdf
      ->Write(0, $context['welcome_message'], '', 0, 'L', true, 0, false, true, 0);
  }
}