You are here

function TCPDFDrupal::DrupalInitialize in TCPDF 7

Sets a bunch of commonly used propeties in the TCPDF object. The propeties set by this function can be safely changed after calling the method. This method also let's the developer to change the header or footer of the pdf document without making his/her own class.

Parameters

array $options: Associative array containing basic settings. 'title' => Title of the document 'subject' => Subject of the document 'author' => Author of the document 'logo_path' => Path to a logo wich is placed to the header 'keywords' => Comma separated list of keywords 'header' => Array 'html' => Html code of the header. 'callback' => Function that generates the header. If 'html' is set, it's ignored. Note: Not working. 'footer' => Array 'html' => Html code of the footer. 'callback' => Function that generates the footer. If 'html' is set, it's ignored. Note: Not working.

File

./tcpdf.class.inc, line 43
Contains \TCPDF\TCPDFDrupal.

Class

TCPDFDrupal
Do not create a new instance of this class manually. Use tcpdf_get_instance().

Code

function DrupalInitialize($options) {
  $title = isset($options['title']) ? $options['title'] : variable_get('site_name', 'Drupal');
  $author = isset($options['author']) ? $options['author'] : variable_get('site_name', 'Drupal');
  $subject = isset($options['subject']) ? $options['subject'] : variable_get('site_name', 'Drupal');
  $keywords = isset($options['keywords']) ? $options['keywords'] : 'pdf, drupal';
  $this->drupalHeader = isset($options['header']) ? $options['header'] : $this->drupalHeader;
  $this->drupalFooter = isset($options['footer']) ? $options['footer'] : $this->drupalFooter;

  // set document information
  $this
    ->SetCreator(PDF_CREATOR);
  $this
    ->SetAuthor($author);
  $this
    ->SetTitle($title);
  $this
    ->SetSubject($subject);
  $this
    ->SetKeywords($keywords);

  // set default header data
  $this
    ->setFooterFont(array(
    PDF_FONT_NAME_DATA,
    '',
    6,
  ));

  // set default monospaced font
  $this
    ->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

  //set margins
  $this
    ->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  $this
    ->SetHeaderMargin(PDF_MARGIN_HEADER);
  $this
    ->SetFooterMargin(PDF_MARGIN_FOOTER);

  //set auto page breaks
  $this
    ->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

  //set image scale factor
  $this
    ->setImageScale(PDF_IMAGE_SCALE_RATIO);

  // set font
  $this
    ->SetFont('dejavusans', '', 8);
  $this
    ->AddPage();
}