<?php


// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

	//Page header
	public function Header() {
global $logo_img;
global $ad_img;
global $footer_img;
global $logo;
global $ad;

if(isset($logo) && $logo!=0){		

		// Logo
		if (count($this->pages) === 1) {
		$image_file = K_PATH_IMAGES.$logo_img;
		$this->Image($image_file, 10, 10, 190, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
		// Set font
		$this->SetFont('helvetica', 'B', 20);}
		
		
		if(isset($ad) && $ad!=0){
		if (count($this->pages) === 2) {
		$img_file = K_PATH_IMAGES.$ad_img;
        $this->Image($img_file, 0, 25, 0, 250, 'JPG', '', '', false, 300, 'C', false, false, 0);
		}
		}
		
		
		
		
}
		}

	// Page footer
	public function Footer() {
global $footer_img;
global $logo;
		
		if(isset($logo) && $logo!=0){
if (count($this->pages) === 1) {
	// Position at 15 mm from bottom
		$this->SetY(-15);
		
		// Set font
		$this->SetFont('helvetica', 'I', 8);
		// Page number
		$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
		$image_file = K_PATH_IMAGES.$footer_img;
		$this->Image($image_file, 10, 250, 190, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
		
	}

	
	}
	}
	
	
}

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($author);
$pdf->SetTitle($doc_title.$rec_id);
$pdf->SetSubject($doc_sub);
$pdf->SetKeywords($doc_keywords);

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

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

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

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

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

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
	require_once(dirname(__FILE__).'/lang/eng.php');
	$pdf->setLanguageArray($l);
}

// set font
$pdf->SetFont('helvetica', '', 9);


// add a page

$pdf->AddPage();


// create some HTML content

















?>