You are here

views_pdf.module in Views PDF 7.2

PDF Views allows the creation of PDF's directly from a view. Without the creation of HTML first.

File

views_pdf.module
View source
<?php

/**
 * @file
 * PDF Views allows the creation of PDF's directly from a view. Without the
 * creation of HTML first.
 */

/**
 * Implements hook_views_api().
 */
function views_pdf_views_api() {
  return array(
    'api' => 3,
  );
}

/**
 * Implements hook_theme().
 */
function views_pdf_theme() {
  return array(
    'views_pdf_plugin_style_table' => array(
      'render element' => 'form',
      'file' => 'views_pdf.admin.inc',
    ),
    'views_pdf_icon' => array(
      'render element' => 'form',
      'variables' => array(
        'url' => NULL,
        'title' => NULL,
      ),
    ),
  );
}

/**
 * This method can be used to load the PDF library class.
 */
function views_pdf_get_new_pdf_instance($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = TRUE, $encoding = 'UTF-8', $diskcache = FALSE) {
  _views_pdf_include_pdf_lib();
  return new PdfTemplate($orientation, $unit, $format, $unicode, $encoding, $diskcache);
}

/**
 * Theme function for the PDF icon of appended PDFs.
 */
function theme_views_pdf_icon($vars) {
  $title = $vars['title'];
  $path = $vars['path'];
  $options = $vars['options'];
  $options['html'] = TRUE;
  $options['attributes']['class'] = 'pdf-icon';
  $image_path = drupal_get_path('module', 'views_pdf') . '/images/pdf.png';
  $image = theme('image', array(
    'path' => $image_path,
    'title' => $title,
    'alt' => $titl,
  ));
  if ($image) {
    return l($image, $path, $options);
  }
}

/**
 * This method can be used to applyaapplypplyget all available fonts.
 */
function views_pdf_get_font_list() {
  _views_pdf_include_pdf_lib();
  return PdfTemplate::getAvailableFontsCleanList();
}

/**
 * This method can be used to get all available templates.
 */
function views_pdf_get_pdf_templates() {
  _views_pdf_include_pdf_lib();
  return PdfTemplate::getAvailableTemplates();
}

/**
 * This method returns all available hyphenation patterns (paths to files).
 */
function views_pdf_get_hyphenations() {
  _views_pdf_include_pdf_lib();
  return PdfTemplate::getAvailableHyphenatePatterns();
}

/**
 * This method can be used to return a list of posible page formats.
 */
function views_pdf_get_page_formats() {
  $format['custom'] = t('Custom');
  $format['4A0'] = '4A0';
  $format['2A0'] = '2A0';
  $format['A0'] = 'A0';
  $format['A1'] = 'A1';
  $format['A2'] = 'A2';
  $format['A3'] = 'A3';
  $format['A4'] = 'A4';
  $format['A5'] = 'A5';
  $format['A6'] = 'A6';
  $format['A7'] = 'A7';
  $format['A8'] = 'A8';
  $format['A9'] = 'A9';
  $format['A10'] = 'A10';
  $format['B0'] = 'B0';
  $format['B1'] = 'B1';
  $format['B2'] = 'B2';
  $format['B3'] = 'B3';
  $format['B4'] = 'B4';
  $format['B5'] = 'B5';
  $format['B6'] = 'B6';
  $format['B7'] = 'B7';
  $format['B8'] = 'B8';
  $format['B9'] = 'B9';
  $format['B10'] = 'B10';
  $format['C0'] = 'C0';
  $format['C1'] = 'C1';
  $format['C2'] = 'C2';
  $format['C3'] = 'C3';
  $format['C4'] = 'C4';
  $format['C5'] = 'C5';
  $format['C6'] = 'C6';
  $format['C7'] = 'C7';
  $format['C8'] = 'C8';
  $format['C9'] = 'C9';
  $format['C10'] = 'C10';
  $format['RA0'] = 'RA0';
  $format['RA1'] = 'RA1';
  $format['RA2'] = 'RA2';
  $format['RA3'] = 'RA3';
  $format['RA4'] = 'RA4';
  $format['SRA0'] = 'SRA0';
  $format['SRA1'] = 'SRA1';
  $format['SRA2'] = 'SRA2';
  $format['SRA3'] = 'SRA3';
  $format['SRA4'] = 'SRA4';
  $format['LETTER'] = 'LETTER';
  $format['LEGAL'] = 'LEGAL';
  $format['EXECUTIVE'] = 'EXECUTIVE';
  $format['FOLIO'] = 'FOLIO';
  $format['MEMO'] = 'MEMO';
  return $format;
}

/**
 * Get the PDF class.
 */
function _views_pdf_include_pdf_lib() {
  module_load_include('php', 'views_pdf', 'views_pdf_template');
}

/**
 * For backward compatibilty (< 5.3) we implemented
 * this function by our self. If we are in a newer
 * environment, then this is obsolete.
 *
 */
if (!function_exists('array_replace_recursive')) {

  /**
   * Internal php function backport to PHP < 5.3.
   */
  function array_replace_recursive($array, $array1) {
    if (!function_exists('recurse')) {

      /**
       * Internal function of array_replace_recursive().
       */
      function recurse($array, $array1) {
        foreach ($array1 as $key => $value) {

          // Create new key in $array, if it is empty or not an array.
          if (!isset($array[$key]) || isset($array[$key]) && !is_array($array[$key])) {
            $array[$key] = array();
          }

          // Overwrite the value in the base array.
          if (is_array($value)) {
            $value = recurse($array[$key], $value);
          }
          $array[$key] = $value;
        }
        return $array;
      }

      // Handle the arguments, merge one by one.
      $args = func_get_args();
      $array = $args[0];
      if (!is_array($array)) {
        return $array;
      }
      for ($i = 1; $i < count($args); $i++) {
        if (is_array($args[$i])) {
          $array = recurse($array, $args[$i]);
        }
      }
      return $array;
    }
  }
}

Functions

Namesort descending Description
theme_views_pdf_icon Theme function for the PDF icon of appended PDFs.
views_pdf_get_font_list This method can be used to applyaapplypplyget all available fonts.
views_pdf_get_hyphenations This method returns all available hyphenation patterns (paths to files).
views_pdf_get_new_pdf_instance This method can be used to load the PDF library class.
views_pdf_get_page_formats This method can be used to return a list of posible page formats.
views_pdf_get_pdf_templates This method can be used to get all available templates.
views_pdf_theme Implements hook_theme().
views_pdf_views_api Implements hook_views_api().
_views_pdf_include_pdf_lib Get the PDF class.