Skip to content

Instantly share code, notes, and snippets.

@musaid
Created December 2, 2012 03:45
Show Gist options
  • Save musaid/4186868 to your computer and use it in GitHub Desktop.
Save musaid/4186868 to your computer and use it in GitHub Desktop.
Allied PDF Printing
<?php
/**
* Allied PDF - A Class to print the policy documents as PDF files from the relevant data
*
* @usage Please refer to the associated documentation and/or the inline documentation
* @author musaid <musaid@live.com>
* @version v0.1
*/
// path to the fpdf library
require('src/fpdf.php');
class AlliedPDF extends FPDF
{
// available data formats
const SINGLE_LINE = 'single_line';
const MULTI_LINE = 'multi_line';
const SINGLE_COLUMN_TABLE = 'single_column_table';
const SINGLE_COLUMN_TABLE_WIDE = 'single_column_table_wide';
const DOUBLE_COLUMN_TABLE = 'double_column_table';
const MULTI_COLUMN_TABLE = 'multi_column_table';
// policy no for the pdf
public $policy_no = 'P-001/12/00004';
// default font styles
protected $_default_font = 'Arial';
protected $_default_font_color = '#000000';
protected $_default_font_style = '';
protected $_default_font_size = 9;
// default cell height
protected $_default_cell_height = 4;
protected $_lm = 10; // left margin
protected $_tm = 40; // top margin
protected $_rm = 10; // right margin
protected $_bm = 10; // left margin
// company name and policy title
protected $_company_name = 'Allied Insurance Company of the Maldives Pvt Ltd';
protected $_policy_title = 'Default Policy';
// entered/approved user details
protected $_entered_user = 'default';
protected $_approved_user = 'default';
// created details
protected $_place_created = 'Male\', Maldives';
protected $_date_created = 'date';
// column setters
private $_col = 0; // current column
private $_y0; // ordinate of column start
// table variables
private $_widths;
private $_aligns;
function __construct() {
parent::__construct('P', 'mm', 'A4');
$this->SetAutoPageBreak('auto', 30);
$this->SetMargins($this->_lm, $this->_tm, $this->_rm);
}
/**
* Sets the Policy No
* @param string $p_no Policy No
*/
public function set_policy_no($p_no) {
$this->policy_no = $p_no;
}
/**
* Gets the Policy No
* @return string Policy No
*/
public function get_policy_no() {
return $this->policy_no;
}
/**
* Sets the Default Font Size
* @param int $size Font Size (in mm)
*/
public function set_default_font_size($size) {
$this->_default_font_size = $size;
}
/**
* Gets the Default Font Size
* @return int Font Size (in mm)
*/
public function get_default_font_size() {
return $this->_default_font_size;
}
/**
* Sets the Default Font Color
* @param string $color Font Color (in hex color code - #ff0000)
*/
public function set_default_font_color($color) {
(!empty($color) && preg_match('/^#(?:[0-9a-fA-F]{3}){1,2}$/', $color) === 1) ? $this->_default_font_color = $color : $this->_default_font_color = '#000000';
}
/**
* Gets the Default Font Color
* @return string Font Color (in hex color code - #000000)
*/
public function get_default_font_color() {
return $this->_default_font_color;
}
/**
* Sets the Default Font Style
* @param string $style Font Style (accepted values are => '' for Regular, 'B' for Bold, 'I' for Italic, 'U' for Underline)
*/
public function set_default_font_style($style) {
$this->_default_font_style = $style;
}
/**
* Gets the Default Font Style
* @return string Default Font Style
*/
public function get_default_font_style() {
return $this->_default_font_style;
}
/**
* Sets the Default Font Family. It can be either a name defined by AddFont() of FPDF Class or one of the standard families (case insensitive)
* Courier/Helvetica/Arial/Times/Symbol/ZapfDingbats
*
* @param string $font Default Font Family
*/
public function set_default_font($font) {
$this->_default_font = $font;
}
/**
* Gets the Default Font Family
* @return string Font Family Name
*/
public function get_default_font() {
return $this->_default_font;
}
/**
* Sets the default Cell/Line Height for the text printed
* @param int $h Height (in mm)
*/
public function set_default_cell_height($h) {
$this->_default_cell_height = $h;
}
/**
* Gets the default Cell/Line Height
* @return int Height (in mm)
*/
public function get_default_cell_height() {
return $this->_default_cell_height;
}
/**
* Sets the Right Margin (starting from the right side of the page)
* @param int $margin Margin (in mm)
*/
public function set_right_margin($margin) {
$this->_rm = $margin;
$this->SetRightMargin($this->_rm);
}
/**
* Gets the Right Margin
* @return int Margin (in mm)
*/
public function get_right_margin() {
return $this->_rm;
}
/**
* Sets the Left Margin (starting from the left side of the page)
* @param int $margin Margin (in mm)
*/
public function set_left_margin($margin) {
$this->_lm = $margin;
$this->SetLeftMargin($this->_lm);
}
/**
* Gets the Left Margin
* @return int Margin (in mm)
*/
public function get_left_margin() {
return $this->_lm;
}
/**
* Sets the Top Margin (starting from the top of the page)
* @param int $margin Margin (in mm)
*/
public function set_top_margin($margin) {
$this->_tm = $margin;
$this->SetTopMargin($this->_tm);
}
/**
* Gets the Top Margin
* @return int Margin (in mm)
*/
public function get_top_margin() {
return $this->_tm;
}
/**
* Sets the Bottom Margin (starting from the bottom of the page)
* @param int $margin Margin (in mm)
*/
public function set_bottom_margin($margin) {
$this->_bm = $margin;
$this->SetBottomMargin($this->_bm);
}
/**
* Gets the Bottom Margin
* @return int Margin (in mm)
*/
public function get_bottom_margin() {
return $this->_bm;
}
/**
* Sets the Company Name (used for the signature area)
* @param string $name Company Name
*/
public function set_company_name($name) {
$this->_company_name = $name;
}
/**
* Gets the Company Name
* @return string Company Name
*/
public function get_company_name() {
return $this->_company_name;
}
/**
* Sets the Entered User (the user whom entered the data required for the policy)
* @param string $user Username
*/
public function set_entered_user($user) {
$this->_entered_user = $user;
}
/**
* Gets the Entered User
* @return string Username
*/
public function get_entered_user() {
return $this->_entered_user;
}
/**
* Sets the Approved User (the user whom approved the entered data after verification)
* @param string $user Username
*/
public function set_approved_user($user) {
$this->_approved_user = $user;
}
/**
* Gets the Approved User
* @return string Username
*/
public function get_approved_user() {
return $this->_approved_user;
}
/**
* Sets the Place the Policy was created (or the like)
* @param string $place Place/City/Country
*/
public function set_place_created($place) {
$this->_place_created = $place;
}
/**
* Gets the Place the Policy was created (or the like)
* @return string Place/City/Country
*/
public function get_place_created() {
return $this->_place_created;
}
/**
* Sets the date the policy was created
* @param string $date Date
*/
public function set_date_created($date) {
$this->_date_created = $date;
}
/**
* Gets the date the policy was created
* @return string Date
*/
public function get_date_created() {
return $this->_date_created;
}
/**
* Sets the policy title (used as the title of FPDF class)
* @param string $title Title
*/
public function set_policy_title($title) {
$this->_policy_title = $title;
$this->SetTitle($this->_policy_title);
}
/**
* Gets the policy title
* @return string Title
*/
public function get_policy_title() {
return $this->_policy_title;
}
/**
* Prints the header for the policy pages
*/
public function header() {
// Set the Page Initiation at 40mm
$this->SetY($this->_tm);
// Set the policy number of the document for pages other than the first page
if ($this->page != 1) {
$this->SetFont('Arial','I',8);
$color = $this->_hex_to_rgb('#aaaaaa');
$this->SetTextColor($color[0], $color[1], $color[2]);
$this->Cell(0,$this->_default_cell_height, 'Attached to and forming part of policy number : '.$this->policy_no, 0,1,'R');
$this->_reset();
$this->Ln(1);
}
}
/**
* Prints the Footer for the policy pages
*/
public function footer() {
// set the Y position to -30 mm
$this->SetY(-($this->_bm + 20));
$fch = $this->_default_cell_height;
// set the font details for the electronically generated doc warning
$this->SetFont('Arial','I',8);
$color = $this->_hex_to_rgb('#aaaaaa');
$this->SetTextColor($color[0], $color[1], $color[2]);
$this->Cell(0,$fch,'( this document is generated electronically )',0,1,'C');
$this->SetY(-($this->_bm + 15));
// set back to the defaults
$this->_reset();
// print the Place Title
$this->SetX($this->_lm + 30);
$this->Cell(1,$fch,'Place :',0,0,'R');
// print the Place Text
$this->SetX($this->_lm + 31);
$this->Cell(1,$fch,$this->_place_created,0,0,'L');
// print the Entered By Title
$this->SetX($this->_lm + 127);
$this->Cell(1,$fch,'Entered By :',0,0,'R');
$this->SetX($this->_lm + 128);
$this->Cell(1,$fch,$this->_entered_user,0,1,'L');
// print the Place Title
$this->SetX($this->_lm + 30);
$this->Cell(1,$fch,'Date :',0,0,'R');
// print the Place Text
$this->SetX($this->_lm + 31);
$this->Cell(1,$fch,$this->_date_created,0,0,'L');
// print the Entered By Title
$this->SetX($this->_lm + 127);
$this->Cell(1,$fch,'Approved By :',0,0,'R');
$this->SetX($this->_lm + 128);
$this->Cell(1,$fch,$this->_approved_user,0,1,'L');
$this->Ln();
// set font style for the page no
$this->SetFont('Arial','I',8);
$color = $this->_hex_to_rgb('#aaaaaa');
$this->SetTextColor($color[0], $color[1], $color[2]);
// print the page no
$this->SetX($this->_lm + 186);
$this->Cell(1,$fch,'Page '.str_pad($this->page, 2, '0', STR_PAD_LEFT),0,1,'R');
// restore the defaults
$this->_reset();
}
/**
* Print a Section on the page
* @param string $data json encoded string of the relevant data
* @param string $format formats as defined by this class (accepted arguments are => SINGLE_LINE/DOUBLE_LINE/SINGLE_COLUMN_TABLE
* SINGLE_COLUMN_TABLE_WIDE/DOUBLE_COLUMN_TABLE/MULTI_COLUMN_TABLE)
*/
public function print_section($data, $format)
{
// $data = json_decode($data, true);
if (isset($data['section_title'])) {
if (!isset($data['section_style'])) {
$data['section_style']['title_border'] = 'TB';
$data['section_style']['title_alignment'] = 'L';
$data['section_style']['title_color'] = '#000000';
}
$this->_section_title($data['section_title'], $data['section_style']['title_border'], $data['section_style']['title_alignment'], $data['section_style']['title_color']);
}
$h = $this->_section_body($data['section_data'], $format);
// check for possible page breaks
$this->_check_page_break($h);
}
/**
* Print the signature field for the policy document
* @param string $img_path Absolute Path to the Image used (if any)
* @param integer $w Width of the Image (in pixels)
* @param integer $h Height of the Image (in pixels)
* @param integer $dpi DPI of the Image (in pixels)
* @param string $type Format of the Image used (accepted formats are => JPG/JPEG/PNG)
* @return [type] [description]
*/
public function print_signature($img_path='', $w=100, $h=50, $dpi=72, $type='JPG') {
$x = $this->_lm + 100;
$cw = 75;
$sh = $this->GetY();
$this->Ln(10);
$this->SetX($x);
$this->Cell($cw, $this->_default_cell_height, 'For and on behalf of', 0, 1, 'C');
$this->SetX($x);
$this->Cell($cw, $this->_default_cell_height, $this->_company_name, 0, 1, 'C');
// use an image only if provided, else print enough space
if (!empty($img_path)) {
$this->Ln();
$y = $this->GetY();
$this->Image($img_path, $x, $y, $this->_pixel_to_mm($w, $dpi), $this->_pixel_to_mm($h, $dpi), $type);
$this->Ln($this->_pixel_to_mm($h, $dpi));
} else
$this->Ln(15);
$this->SetX($x);
$this->Cell($cw, $this->_default_cell_height, 'Authorised Signature', 0, 0, 'C');
$fh = $this->GetY();
$this->Ln(6);
$this->_check_page_break($fh - $sh);
}
/**
* Sets the Section Title for the Section
* @param string $title Title for the Section
* @param mixed $border Border (accepted arguments are => 0 for no border, 1 for frame, 'L' for Left Border, 'R' for Right Border
* 'T' for Top Border, 'B' for Bottom Border or any of the string values mixed [like, 'TB' for Top and Bottom])
* @param string $align Alignment of Text (accepted arguments are => 'L' for Left, 'C' for Center, 'R' for Right)
* @param string $color Color for the Printed Text (in hex color code)
* @param string $bg Color for the Background (in hex color code)
*/
protected function _section_title($title, $border=0, $align='C', $color='#000000', $bg='#ffffff')
{
// Arial 10
$this->SetFont('Arial','B',10);
$this->SetX($this->_lm);
// set bg color if bg is color is set
if (!empty($bg) && preg_match('/^#(?:[0-9a-fA-F]{3}){1,2}$/', $bg) === 1) {
$bg_color = $this->_hex_to_rgb($bg);
$this->SetFillColor($bg_color[0], $bg_color[1], $bg_color[2]);
$fill = true;
} else {
$fill = false;
}
// set text color if text color is set
if (!empty($color) && preg_match('/^#(?:[0-9a-fA-F]{3}){1,2}$/', $color) === 1) {
$color = $this->_hex_to_rgb($color);
$this->SetTextColor($color[0], $color[1], $color[2]);
}
// set title with a height of 5mm
$this->MultiCell(0,5,$title,$border,$align, $fill);
// set back to the default text color;
$this->_reset();
// a line break of 1 mm
$this->Ln(1);
}
/**
* Prints the Data for the Section
* @param array $data Data
* @param string $format formats as defined by this class (accepted arguments are => SINGLE_LINE/DOUBLE_LINE/SINGLE_COLUMN_TABLE
* SINGLE_COLUMN_TABLE_WIDE/DOUBLE_COLUMN_TABLE/MULTI_COLUMN_TABLE)
* @return integer Height of the Printed Section (in mm)
*/
protected function _section_body($data, $format) {
// starting height
$section_body_start_height = $this->GetY();
switch($format) {
// handles single line sections
case self::SINGLE_LINE: {
foreach ($data as $line) {
$this->SetX($this->_lm + 5);
$this->SetRightMargin($this->_rm + 5);
$this->MultiCell(0,$this->_default_cell_height,$line,0,'L');
}
$this->Ln(3);
$section_body_end_height = $this->GetY();
$this->SetRightMargin($this->_rm);
}
break;
// handles multi line sections
case self::MULTI_LINE: {
$this->MultiCell(0,$this->_default_cell_height,$data,0,'C');
$this->Ln(3);
$section_body_end_height = $this->GetY();
}
break;
// handles single column tables
case self::SINGLE_COLUMN_TABLE: {
$h = $this->GetY();
foreach ($data as $key => $value) {
$col_width = 55;
$this->SetX($this->_lm);
$this->SetY($h);
$this->SetFont($this->_default_font,'B',$this->_default_font_size);
//$this->Cell(1,$this->_default_cell_height,$key,0,0,'R');
$this->MultiCell($col_width,$this->_default_cell_height, $key, 0, 'R');
$this->_reset();
$kh = $this->GetY();
$this->SetY($h);
$this->SetX($this->_lm + $col_width + 2);
//$this->Cell(1,$this->_default_cell_height,$value,0,1,'L');
$this->MultiCell(0,$this->_default_cell_height, $value, 0, 'L');
$vh = $this->GetY();
if ($kh > $vh)
$h = $kh;
else
$h = $vh;
}
$this->Ln(6);
$section_body_end_height = $this->GetY();
}
break;
// handles single column wide tables
case self::SINGLE_COLUMN_TABLE_WIDE: {
$h = $this->GetY();
foreach ($data as $key => $value) {
$this->_reset();
$col_width = 75;
$this->SetX($this->_lm);
$this->SetY($h);
//$this->Cell(1,$this->_default_cell_height,$key,0,0,'R');
$this->MultiCell($col_width,$this->_default_cell_height, $key, 0, 'L');
$kh = $this->GetY();
$this->SetY($h);
$this->SetX($this->_lm + $col_width + 2);
$this->MultiCell(0,$this->_default_cell_height, $value, 0, 'L');
$vh = $this->GetY();
if ($kh > $vh)
$h = $kh;
else
$h = $vh;
}
$this->Ln(3);
$section_body_end_height = $this->GetY();
}
break;
// handles double column tables
case self::DOUBLE_COLUMN_TABLE: {
$main_h = $this->GetY();
$main_col_width = 90;
$col_h = array();
$x = $this->_lm;
foreach ($data as $data_key => $data_value) {
$this->SetY($main_h);
$h = $this->GetY();
foreach ($data_value as $key => $value) {
$col_width = 40;
$this->SetX($x);
$this->SetY($h);
$this->SetFont($this->_default_font,'B',$this->_default_font_size);
$this->MultiCell($col_width,$this->_default_cell_height, $key, 0, 'R');
$this->_reset();
$kh = $this->GetY();
$this->SetY($h);
$this->SetX($x + $col_width + 2);
$this->MultiCell($main_col_width-$col_width,$this->_default_cell_height, $value, 0, 'L');
$vh = $this->GetY();
if ($kh > $vh)
$h = $kh;
else
$h = $vh;
}
$col_h[$data_key] = $h;
$this->SetLeftMargin($x+$main_col_width);
$x = $this->GetX();
$this->Ln(3);
}
$this->SetY(max($col_h));
$this->SetLeftMargin($this->_lm);
$this->Ln(3);
$section_body_end_height = $this->GetY();
}
break;
// handles multi column tables
case self::MULTI_COLUMN_TABLE: {
$h = $this->_tabulate($data, "#000000");
$this->Ln(3);
$section_body_end_height = $h;
}
break;
// handles default categories
default:
$this->Ln(3);
$section_body_end_height = $this->GetY();
break;
}
// return the total height for the section
return $section_body_end_height - $section_body_start_height;
}
/**
* Tabulates any given data
* @param array $data Data to be tabulated
* @param string $header_fill_color Fill Color for the Header
* @return integer Height of the Printed Table (in mm)
*/
protected function _tabulate($data, $header_fill_color="#000000") {
$cw = array();
$padding = 5;
$this->SetLeftMargin($this->_lm + $padding);
$page_width = 210;
$table_width = ($page_width - $this->_lm - $this->_rm - ($padding * 2));
$j=0;
$total_str_width = 0;
$headers = $data['headers'];
foreach ($headers as $header) {
$str_width = intval($this->GetStringWidth($header));
$cw[$j] = $str_width;
$total_str_width += $str_width;
$j++;
}
$unused_width = $table_width - $total_str_width;
$unused_col_width = $unused_width / $j;
for ($k=0; $k<count($cw); $k++) {
$cw[$k] = intval($cw[$k] + $unused_col_width);
}
// Colors, line width and bold font
$header_fill_color = $this->_hex_to_rgb($header_fill_color);
$this->SetFillColor($header_fill_color[0],$header_fill_color[1],$header_fill_color[2]);
$this->SetTextColor(255);
$this->SetDrawColor($header_fill_color[0],$header_fill_color[1],$header_fill_color[2]);
$this->SetLineWidth(.3);
$this->SetFont('','B');
$header_h = $this->GetY();
$i = 0;
$x = $this->_lm + $padding;
// header
for($i=0;$i<count($headers);$i++) {
$this->SetY($header_h);
$this->SetX($x);
$this->MultiCell($cw[$i], $this->_default_cell_height, $headers[$i], 1, 'C', true);
$x = $x + $cw[$i];
}
// Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
unset($data['headers']);
$this->_set_widths($cw);
foreach ($data as $row) {
$this->_row($row);
}
$this->SetLeftMargin($this->_lm);
$this->_reset();
return $this->GetY();
}
/**
* Converts Pixels to mm
* @param integer $p Value (in pixels)
* @param integer $dpi DPI value (in pixels)
* @return integer Value (in mm)
*/
private function _pixel_to_mm($p=100, $dpi=72) {
return round(($p * 25.4) / $dpi);
}
/**
* Sets the widths for the table columns
* @param array $w Widths (in mm)
*/
private function _set_widths($w) {
$this->_widths = $w;
}
/**
* Sets the alignment for the table rows
* @param array $a Alignments (as 'L'/'C'/'R')
*/
private function _set_aligns($a) {
$this->_aligns = $a;
}
/**
* Prints the given array of data as rows
* @param array $data Data to be printed as rows
*/
private function _row($data) {
// calculate the height of the row
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb, $this->_nb_lines($this->_widths[$i], $data[$i]));
$h=5*$nb;
// issue a page break first if needed
$this->_check_page_break($h);
// draw the cells of the row
for($i=0;$i<count($data);$i++) {
$w=$this->_widths[$i];
$a=isset($this->_aligns[$i]) ? $this->_aligns[$i] : 'L';
// save the current position
$x=$this->GetX();
$y=$this->GetY();
// draw the border
$this->Rect($x, $y, $w, $h);
// print the text
$this->MultiCell($w, 5, $data[$i], 0, $a);
// put the position to the right of the cell
$this->SetXY($x+$w, $y);
}
// go to the next line
$this->Ln($h);
}
/**
* If the height h would cause an overflow, add a new page immediately
* @param integer $h Height (in mm)
*/
private function _check_page_break($h) {
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}
/**
* Computes the number of lines a MultiCell of width w will take
* @param integer $w Width for MultiCell (in mm)
* @param string $txt Text to be put inside the MultiCell
* @return integer Number of Lines the provided text would occupy
*/
private function _nb_lines($w, $txt) {
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r", '', $txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
/**
* Resets the settings to defaults
*/
private function _reset() {
// set back to the default font and size
$this->SetFont($this->_default_font, $this->_default_font_style, $this->_default_font_size);
// set the default text color
$color = $this->_hex_to_rgb($this->_default_font_color);
$this->SetTextColor($color[0], $color[1], $color[2]);
}
/**
* Convert given hex color value to it's associated rgb value
* @param string $color value of the color in hex (#000000)
* @return array array of color values as array(red, green, blue)
*/
private function _hex_to_rgb($color) {
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return array($r, $g, $b);
}
/**
* Convert given rgb value to it's associated hex color value
* @param integer $r value of red (0 to 255)
* @param integer $g value of green (0 to 255)
* @param integer $b value of blue (0 to 255)
* @return string color value in hex
*/
private function _rgb_to_hex($r, $g=-1, $b=-1) {
if (is_array($r) && sizeof($r) == 3)
list($r, $g, $b) = $r;
$r = intval($r); $g = intval($g);
$b = intval($b);
$r = dechex($r<0?0:($r>255?255:$r));
$g = dechex($g<0?0:($g>255?255:$g));
$b = dechex($b<0?0:($b>255?255:$b));
$color = (strlen($r) < 2?'0':'').$r;
$color .= (strlen($g) < 2?'0':'').$g;
$color .= (strlen($b) < 2?'0':'').$b;
return '#'.$color;
}
}
?>
<?php
require_once('AlliedPDF.php');
class CargoPolicyPDF extends AlliedPDF {
function __construct() {
parent::__construct();
}
}
$main = array(
"section_title" => "MARINE CARGO - SINGLE VOYAGE SEA IMPORT/EXPORT POLICY",
"section_data" => "THE COMPANY, hereby agree, in consideration of payment to us or on behalf of the Assured of the premium specified in the Schedule, to insure against loss, damage, liability or expense in the manner as shown in the Schedule and on the reverse hereof.",
"section_style" => array(
"title_border" => "TB",
"title_alignment" => "C",
"title_color" => "#0D4F8B"
)
);
$schedule = array(
"section_title" => "SCHEDULE",
"section_data" => array(
array(
"Policy No :" => "P-202/12/00004",
"Previous Policy No. :" => "",
"Date :" => "2012-10-13",
"Agent/Broker :" => "Agent/Broker Text",
"" => "",
"Period of Insurance :" => "From 18:21:19 On 2012-10-13 To 00:00:00 Of 2012-10-13",
"Receipt No. & Date :" => "RMO/12/00204 - 2012-10-13"
),
array(
"Insured Name :" => "Test User",
"Address :" => "Test Address",
"Street :" => "Test Street",
"City :" => "Test City, Maldives",
"Tel./Fax/Email :" => "7897897/_/musaid@alliedmaldives.net"
)
),
"section_style" => array(
"title_border" => "TB",
"title_alignment" => "C",
"title_color" => "#0D4F8B"
)
);
$pdf = new CargoPolicyPDF();
$pdf->SetAuthor('musaid');
$pdf->AddPage();
$pdf->print_section($main, AlliedPDF::MULTI_LINE);
$pdf->print_section($schedule, AlliedPDF::DOUBLE_COLUMN_TABLE);
$pdf->print_signature('img/letterhead.jpg', 409, 81, 72, 'JPG');
$pdf->Output('', 'I');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment