You are here

tcpdf_example.module in TCPDF 8

Same filename and directory in other branches
  1. 7 tcpdf_example/tcpdf_example.module

Provide examples of using the TCPDF module.

File

tcpdf_example/tcpdf_example.module
View source
<?php

/**
 * @file
 * Provide examples of using the TCPDF module.
 */

/**
 * Implements hook_theme().
 */
function tcpdf_example_theme($existing, $type, $theme, $path) {
  switch ($type) {
    case 'module':
      return array(
        'tcpdf_example_basic_html' => array(
          'template' => 'tcpdf_example_basic_html',
        ),
      );
      break;
  }
}

/**
 * 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.
 *
 * @param type $tcpdf TCPDFDrupal instance. It can be used as $this in the
 *   Header() function of a siebling of TCPDF.
 */
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);
  }
}

Functions

Namesort descending Description
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.
tcpdf_example_theme Implements hook_theme().