You are here

function _webform2pdf_init_tcpdf in Webform2PDF 7.4

Same name and namespace in other branches
  1. 6.2 webform2pdf.module \_webform2pdf_init_tcpdf()
  2. 6 webform2pdf.module \_webform2pdf_init_tcpdf()
  3. 7.3 webform2pdf.module \_webform2pdf_init_tcpdf()
1 call to _webform2pdf_init_tcpdf()
theme_webform2pdf_pdf_init in includes/webform2pdf.theme.inc

File

includes/webform2pdf.theme.inc, line 6

Code

function _webform2pdf_init_tcpdf($node, $template) {
  global $base_url;
  $tcpdf_dir = libraries_get_path('tcpdf');
  if (defined('K_TCPDF_EXTERNAL_CONFIG')) {
    define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
    define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
    define('K_PATH_URL', $base_url);
    define('K_PATH_FONTS', $tcpdf_dir . '/fonts/');
    define('K_PATH_CACHE', $tcpdf_dir . '/cache/');
    define('K_PATH_IMAGES', '');
    define('K_BLANK_IMAGE', $tcpdf_dir . '/images/_blank.png');
    define('K_CELL_HEIGHT_RATIO', 1.25);
    define('K_SMALL_RATIO', 2 / 3);
  }
  if (is_file($tcpdf_dir . '/tcpdf.php')) {
    include_once drupal_get_path('module', 'webform2pdf') . '/webform2pdf.class.inc';
    $font = array(
      variable_get('p_font_family', 'dejavuserif'),
      '',
      variable_get('p_font_size', 12),
    );

    // create new PDF document
    $pdf = new W2PDF($template['page_orientation'], 'mm', $template['page_format'], TRUE);

    // set document information
    $pdf
      ->SetCreator(variable_get('site_name', 'Drupal'));
    $pdf
      ->SetAuthor($node->name);
    $pdf
      ->SetTitle($node->title);
    $pdf
      ->setPDFVersion('1.6');
    return $pdf;
  }
  else {
    return;
  }
}