Exemple #1
2
 public final function generate_attendees_PDF($tickets_list)
 {
     $this->load_pdf_libraries();
     $pdf = new FPDF();
     $ecp = TribeEvents::instance();
     $pdf->AddFont('OpenSans', '', 'opensans.php');
     $pdf->AddFont('SteelFish', '', 'steelfish.php');
     $pdf->SetTitle('EventTicket');
     $pdf->SetAuthor('The Events Calendar');
     $pdf->SetCreator('The Events Calendar');
     $defaults = array('event_id' => 0, 'ticket_name' => '', 'holder_name' => '', 'order_id' => '', 'ticket_id' => '', 'security_code' => '');
     foreach ($tickets_list as $ticket) {
         $ticket = wp_parse_args($ticket, $defaults);
         $event = get_post($ticket['event_id']);
         $venue_id = tribe_get_venue_id($event->ID);
         $venue = !empty($venue_id) ? get_post($venue_id)->post_title : '';
         $address = tribe_get_address($event->ID);
         $zip = tribe_get_zip($event->ID);
         $state = tribe_get_stateprovince($event->ID);
         $city = tribe_get_city($event->ID);
         $pdf->AddPage();
         $pdf->SetDrawColor(28, 166, 205);
         $pdf->SetFillColor(28, 166, 205);
         $pdf->Rect(15, 10, 180, 34, 'F');
         $pdf->SetTextColor(255);
         $pdf->SetFont('OpenSans', '', 10);
         $pdf->SetXY(30, 15);
         $pdf->Write(5, __('EVENT NAME:', 'tribe-events-calendar'));
         $pdf->SetXY(30, 28);
         $pdf->SetFont('SteelFish', '', 53);
         $title = strtoupper(utf8_decode($event->post_title));
         $size = 53;
         while ($pdf->GetStringWidth($title) > 151) {
             $size--;
             $pdf->SetFontSize($size);
         }
         $pdf->Write(5, $title);
         $pdf->SetTextColor(41);
         $pdf->SetFont('OpenSans', '', 10);
         $pdf->SetXY(30, 50);
         $pdf->Write(5, __('TICKET HOLDER:', 'tribe-events-calendar'));
         $pdf->SetXY(104, 50);
         $pdf->Write(5, __('LOCATION:', 'tribe-events-calendar'));
         $pdf->SetFont('SteelFish', '', 30);
         $pdf->SetXY(30, 59);
         $holder = strtoupper(utf8_decode($ticket['holder_name']));
         $size = 30;
         while ($pdf->GetStringWidth($holder) > 70) {
             $size--;
             $pdf->SetFontSize($size);
         }
         $pdf->Write(5, $holder);
         $pdf->SetXY(104, 59);
         $venue = strtoupper(utf8_decode($venue));
         $size = 30;
         while ($pdf->GetStringWidth($venue) > 70) {
             $size--;
             $pdf->SetFontSize($size);
         }
         $pdf->Write(5, $venue);
         $pdf->SetXY(104, 71);
         $address = strtoupper(utf8_decode($address));
         $size = 30;
         while ($pdf->GetStringWidth($address) > 70) {
             $size--;
             $pdf->SetFontSize($size);
         }
         $pdf->Write(5, $address);
         $pdf->SetXY(104, 83);
         $address2 = array($city, $state, $zip);
         $address2 = array_filter($address2);
         $address2 = join(', ', $address2);
         $address2 = strtoupper(utf8_decode($address2));
         $size = 30;
         while ($pdf->GetStringWidth($address2) > 70) {
             $size--;
             $pdf->SetFontSize($size);
         }
         $pdf->Write(5, $address2);
         $pdf->Line(15, 97, 195, 97);
         $pdf->SetFont('OpenSans', '', 10);
         $pdf->SetXY(30, 105);
         $pdf->Write(5, __('ORDER:', 'tribe-events-calendar'));
         $pdf->SetXY(80, 105);
         $pdf->Write(5, __('TICKET:', 'tribe-events-calendar'));
         $pdf->SetXY(120, 105);
         $pdf->Write(5, __('VERIFICATION:', 'tribe-events-calendar'));
         $pdf->SetFont('SteelFish', '', 53);
         $pdf->SetXY(30, 118);
         $pdf->Write(5, $ticket['order_id']);
         $pdf->SetXY(80, 118);
         $pdf->Write(5, $ticket['ticket_id']);
         $pdf->SetXY(120, 118);
         $pdf->Write(5, $ticket['security_code']);
         $pdf->Rect(15, 135, 180, 15, 'F');
         $pdf->SetTextColor(255);
         $pdf->SetFont('OpenSans', '', 10);
         $pdf->SetXY(30, 140);
         $pdf->Write(5, get_bloginfo('name'));
         $pdf->SetXY(104, 140);
         $pdf->Write(5, get_home_url());
     }
     $upload_path = wp_upload_dir();
     $upload_url = $upload_path['url'];
     $upload_path = $upload_path['path'];
     $filename = wp_unique_filename($upload_path, sanitize_file_name(md5(time())) . '.pdf');
     $upload_path = trailingslashit($upload_path) . $filename;
     $upload_url = trailingslashit($upload_url) . $filename;
     $pdf->Output($upload_path, 'F');
     return array($upload_path, $upload_url);
 }
	function generatePDFReport(Report $report, $results){
		
		$types = self::get_report_column_types($report->getId());
		$ot = ObjectTypes::findById($report->getReportObjectTypeId());
		eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
		$externalCols = $managerInstance->getExternalColumns();
		$filename = str_replace(' ', '_',$report->getObjectName()).date('_YmdHis');
		
		$actual_encoding = mb_internal_encoding();
		
		Hook::fire("report_header", $ot, $results['columns']);
		
		$pageLayout = $_POST['pdfPageLayout'];
		$fontSize = $_POST['pdfFontSize'];
		include_once(LIBRARY_PATH . '/pdf/fpdf.php');
		$pdf = new FPDF($pageLayout);
		$pdf->setTitle($report->getObjectName());
		$pdf->AddPage();
		$pdf->SetFont('Arial','',$fontSize);
		$pdf->Cell(80);
		if (strtoupper($actual_encoding) == "UTF-8") {
			$report_title = html_entity_decode($report->getObjectName(), ENT_COMPAT);
		} else {
			$report_title = iconv(mb_internal_encoding(), "UTF-8", html_entity_decode($report->getObjectName(), ENT_COMPAT));
		}
		$pdf->Cell(30, 10, $report_title);
		$pdf->Ln(20);
		$colSizes = array();
		$maxValue = array();
		$fixed_col_sizes = array();
		foreach($results['rows'] as $row) {
			$i = 0;
			array_shift ($row);
			foreach($row as $k => $value){
				if(!isset($maxValue[$i])) $maxValue[$i] = '';
				if(strlen(strip_tags($value)) > strlen($maxValue[$i])){
					$maxValue[$i] = strip_tags($value);
				}
				$i++;  
			}
    	}
    	$k=0;
    	foreach ($maxValue as $str) {
    		$col_title_len = $pdf->GetStringWidth(array_var($results['columns'], $k));
    		$colMaxTextSize = max($pdf->GetStringWidth($str), $col_title_len);
    		$db_col = array_var($results['columns'], $k);
    		$colType = array_var($types, array_var($results['db_columns'], $db_col, ''), '');
    		if($colType == DATA_TYPE_DATETIME && !($report->getObjectTypeName() == 'event' && $results['db_columns'][$db_col] == 'start')){
    			$colMaxTextSize = $colMaxTextSize / 2;
    			if ($colMaxTextSize < $col_title_len) $colMaxTextSize = $col_title_len;
    		}
    		$fixed_col_sizes[$k] = $colMaxTextSize;
    		$k++;
    	}
    	
    	$fixed_col_sizes = self::fix_column_widths(($pageLayout=='P'?172:260), $fixed_col_sizes);
    	
    	$max_char_len = array();
		$i = 0;
		foreach($results['columns'] as $col){
			$colMaxTextSize = $fixed_col_sizes[$i];
			$colFontSize = $colMaxTextSize + 5;
			$colSizes[$i] = $colFontSize;
			
			if (strtoupper($actual_encoding) == "UTF-8") {
				$col_name = html_entity_decode($col, ENT_COMPAT);
			} else {
				$col_name = iconv(mb_internal_encoding(), "UTF-8", html_entity_decode($col, ENT_COMPAT));
			}
			$pdf->Cell($colFontSize, 7, $col_name);
    		$max_char_len[$i] = self::get_max_length_from_pdfsize($pdf, $colFontSize);
    		$i++;
		}
		
		$lastColX = $pdf->GetX();
		$pdf->Ln();
		$pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
		foreach($results['rows'] as $row) {
			$i = 0;
			$more_lines = array();
			$col_offsets = array();
			foreach($row as $k => $value){
				if ($k == 'object_type_id') continue;
				$db_col = isset($results['columns'][$i]) && isset($results['db_columns'][$results['columns'][$i]]) ? $results['db_columns'][$results['columns'][$i]] : '';

				$cell = format_value_to_print($db_col, html_to_text($value), ($k == 'link'?'':array_var($types, $k)), array_var($row, 'object_type_id'), '', is_numeric(array_var($results['db_columns'], $k)) ? "Y-m-d" : user_config_option('date_format'));
				
				if (strtoupper($actual_encoding) == "UTF-8") {
					$cell = html_entity_decode($cell, ENT_COMPAT);
				} else {
					$cell = iconv(mb_internal_encoding(), "UTF-8", html_entity_decode($cell, ENT_COMPAT));
				}
				
				$splitted = self::split_column_value($cell, $max_char_len[$i]);
				$cell = $splitted[0];
				if (count($splitted) > 1) {
					array_shift($splitted);
					$ml = 0;
					foreach ($splitted as $sp_val) {
						if (!isset($more_lines[$ml]) || !is_array($more_lines[$ml])) $more_lines[$ml] = array();
						$more_lines[$ml][$i] = $sp_val;
						$ml++;
					}
					$col_offsets[$i] = $pdf->x;
				}
				
				$pdf->Cell($colSizes[$i],7,$cell);
				$i++;
			}
			foreach ($more_lines as $ml_values) {
				$pdf->Ln();
				foreach ($ml_values as $col_idx => $col_val) {
					$pdf->SetX($col_offsets[$col_idx]);
					$pdf->Cell($colSizes[$col_idx],7,$col_val);
				}
			}
			$pdf->Ln();
			$pdf->SetDrawColor(220, 220, 220);
			$pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
			$pdf->SetDrawColor(0, 0, 0);
		}
		$filename = ROOT."/tmp/".gen_id().".pdf";
		$pdf->Output($filename, "F");
		download_file($filename, "application/pdf", $report->getObjectName(), true);
		unlink($filename);
		die();
	}
function pdf_export_dots(&$dots, &$more)
{
    # PLEASE FOR TO BE CACHING ME, OBIWAN...
    # (20110120/straup)
    $w = 11;
    $h = 8.5;
    $margin = 0.5;
    $dpi = 72;
    $header_h = 0.2;
    $row_h = 0.2;
    $col_width = 1.25;
    # Here we go...
    $pdf = new FPDF("P", "in", array($w, $h));
    $pdf->setMargins($margin, $margin);
    # The legend gets added below (once we've figured out what page
    # each dot is on) but we'll just declare it here.
    $legend = array();
    $count_legend_items = floor($h / ($row_h * 1.4));
    $count_clusters = ceil(count($dots) / $count_legend_items);
    # Just turn clusters off for now... the map rendering time
    # is still too long for multiple map images (20110120/straup)
    $count_clusters = 1;
    $clusters = array();
    if ($count_clusters == 1) {
        $clusters = array($dots);
    } else {
        $points = array();
        $i = 0;
        foreach ($dots as $dot) {
            $points[] = array('x' => (double) $dot['longitude'], 'y' => (double) $dot['latitude'], 'id' => $dot['id'], 'idx' => $i);
            $i++;
        }
        $_clusters = kmeans_cluster($points, $count_clusters);
        foreach ($_clusters as $_cluster) {
            $_dots = array();
            foreach ($_cluster as $_pt) {
                $_dots[] = $dots[$pt['idx']];
            }
            $clusters[] = $_dots;
        }
    }
    #
    # First generate all the maps
    #
    $maps = array();
    $img_more = array('width' => $h * $dpi, 'height' => $h * $dpi, 'dot_size' => 15);
    foreach ($clusters as $dots) {
        list($map, $gd_img) = maps_image_for_dots($dots, $img_more);
        $maps[] = maps_gd_to_png($gd_img, 'pdf');
    }
    # Now figure out the what is the what of the dots
    $columns = array();
    $cols_per_page = floor(($w - $margin * 2) / $col_width);
    $count_cols = count($more['columns']);
    $pages_per_row = ceil($count_cols / $cols_per_page);
    # See this? We're adding enough extra columns and re-counting
    # everything in order to ensure that every page for each row
    # has an 'id' column
    if ($pages_per_row > 1) {
        $_count = $count_cols + ($pages_per_row - 1);
        $pages_per_row = ceil($_count / $cols_per_page);
    }
    # First, chunk out the header in (n) pages and measure the
    # height of the (header) row itself
    $_h = $header_h * 1.3;
    $pdf->SetFont('Helvetica', 'B', 10);
    for ($i = 0; $i < $count_cols; $i++) {
        $col_name = $more['columns'][$i];
        $b = floor($i / $cols_per_page);
        if (!is_array($columns[$b])) {
            $columns[] = array();
        }
        $columns[$b][] = $col_name;
        $str_width = ceil($pdf->GetStringWidth($more['columns'][$i]));
        if ($str_width > $col_width) {
            $lines = ceil($str_width / $col_width);
            $_h = max($_h, $lines * $header_h);
        }
    }
    $header_h = $_h;
    # make sure every page has an 'id' field
    # (see above)
    $count_columns = count($columns);
    for ($i = 0; $i < $count_columns; $i++) {
        $cols = $columns[$i];
        if (!in_array('id', $cols)) {
            array_unshift($cols, 'id');
            $columns[$i] = $cols;
        }
        # move stuff around so that we keep the pages nice and tidy
        if (count($columns[$i]) > $cols_per_page) {
            $to_keep = array_slice($columns[$i], 0, $cols_per_page);
            $extra = array_slice($columns[$i], $cols_per_page);
            $columns[$i] = $to_keep;
            $columns[$i + 1] = $extra;
        }
    }
    # Now work out the height of each row of dots
    $row_heights = array();
    $pdf->SetFont('Helvetica', '', 10);
    foreach ($dots as $dot) {
        $_h = $row_h;
        foreach ($dot as $key => $value) {
            $str_width = ceil($pdf->GetStringWidth($value));
            if ($str_width > $col_width) {
                $lines = ceil($str_width / $col_width);
                $_h = max($_h, $lines * $row_h);
            }
        }
        $row_heights[] = $_h * 1.1;
    }
    # Now sort everything in to pages
    $pages = array();
    $page = 0;
    $count_dots = count($dots);
    $dot_idx = 0;
    $y = $margin + $header_h;
    while ($dot_idx < $count_dots) {
        $dot = $dots[$dot_idx];
        $row_height = $row_heights[$dot_idx];
        # will this row bleed off the current page ($page) ?
        $goto_nextpage = 0;
        if ($y + $row_height > $h - $margin * 1.5) {
            $goto_nextpage = 1;
        }
        if ($goto_nextpage) {
            $page += $pages_per_row;
            $y = $margin + $header_h;
        }
        $y += $row_height;
        # set up information for legend
        $legend[$dot['id']] = array('page' => $page + 2, 'id' => $dot['id'], 'latitude' => $dot['latitude'], 'longitude' => $dot['longitude'], 'ymd' => gmdate('Y-m-d', strtotime($dot['created'])));
        #
        $j = 0;
        foreach ($columns as $cols) {
            $_row = array();
            foreach ($cols as $name) {
                $_row[] = $dot[$name];
            }
            $page_idx = $page + $j;
            if (!is_array($pages[$page_idx])) {
                $pages[$page_idx] = array(array('row' => $cols, 'bold' => 1, 'height' => $header_h));
            }
            $pages[$page_idx][] = array('row' => $_row, 'height' => $row_height);
            $j++;
        }
        $dot_idx++;
    }
    #
    # ZOMG... finally publish the thing...
    #
    # First, display all the maps and corresponding
    # legends
    function sort_by_lat($a, $b)
    {
        if ($a['latitude'] == $b['latitude']) {
            return 0;
        }
        return $a['latitude'] > $b['latitude'] ? -1 : 1;
    }
    $count_clusters = count($clusters);
    for ($i = 0; $i < $count_clusters; $i++) {
        $dots = $clusters[$i];
        $_legend = array();
        $j = 0;
        foreach ($dots as $dot) {
            $_legend[$dot['id']] = $legend[$dot['id']];
            $j++;
            if ($j >= $count_legend_items) {
                break;
            }
        }
        usort($_legend, "sort_by_lat");
        $pdf->AddPage();
        $pdf->Image($maps[$i], 0, 0, 0, 0, 'PNG');
        $pdf->SetFont('Helvetica', '', 10);
        $x = $h + $margin;
        $y = $margin;
        foreach ($_legend as $dot) {
            $text = "{$dot['id']} / pg. {$dot['page']}";
            $pdf->SetXY($x, $y);
            $pdf->Cell(0, $row_h, $text);
            $loc = new MMaps_Location($dot['latitude'], $dot['longitude']);
            $pt = $map->locationPoint($loc);
            $x1 = $x - $margin / 8;
            $y1 = $y + $row_h / 2;
            $x2 = $pt->x / $dpi;
            $y2 = $pt->y / $dpi;
            $pdf->Line($x1, $y1, $x2, $y2);
            $y += $row_h * 1.1;
        }
    }
    # Now the rows (of dots)
    foreach ($pages as $page) {
        $pdf->AddPage();
        $x = $margin;
        $y = $margin;
        $z = 0;
        foreach ($page as $data) {
            $style = $data['bold'] ? 'B' : '';
            $pdf->SetFont('Helvetica', $style, 10);
            $x_offset = $col_width * 0.1;
            $y_offset = $data['height'] * 0.1;
            $max_width = $col_width - $x_offset * 3;
            $bg = $z % 2 ? 255 : 235;
            $z++;
            foreach ($data['row'] as $value) {
                $value = trim($value);
                $width = $pdf->GetStringWidth($value);
                $pdf->SetFillColor($bg);
                $pdf->Rect($x, $y, $col_width, $data['height'], 'F');
                # Don't bother with MultiCell - it is behaving
                # badly (20110120/straup)
                if ($width < $max_width) {
                    $pdf->SetXY($x + $x_offset, $y + $y_offset);
                    $pdf->Cell(0, $row_h, $value);
                } else {
                    $_x = $x;
                    $_y = $y;
                    $lines = array();
                    $buffer = '';
                    foreach (str_split($value) as $char) {
                        if ($buffer == '' && $char == ' ') {
                            continue;
                        }
                        $buffer .= $char;
                        $width = $pdf->GetStringWidth($buffer);
                        if ($width >= $max_width) {
                            $lines[] = $buffer;
                            $buffer = '';
                        }
                    }
                    if (strlen($buffer)) {
                        $lines[] = $buffer;
                        $buffer = '';
                    }
                    foreach ($lines as $ln) {
                        $pdf->SetXY($_x + $x_offset, $_y + $y_offset);
                        $pdf->Cell(0, $row_h, $ln);
                        $_y += $row_h * 0.8;
                    }
                }
                $x += $col_width;
            }
            $x = $margin;
            $y += $data['height'];
        }
    }
    # Go!
    $pdf->Close();
    $pdf->Output($more['path'], 'F');
    $pdf = null;
    foreach ($maps as $map_img) {
        if (!unlink($map_img)) {
            error_log("[EXPORT] (pdf) unlink {$map_img} : {$ok}");
        }
    }
    return $more['path'];
}
 function generatePDFReport($report, $results)
 {
     $types = self::get_report_column_types($report->getId());
     eval('$managerInstance = ' . $report->getObjectType() . "::instance();");
     $externalCols = $managerInstance->getExternalColumns();
     $filename = str_replace(' ', '_', $report->getName()) . date('_YmdHis');
     $pageLayout = $_POST['pdfPageLayout'];
     $fontSize = $_POST['pdfFontSize'];
     include_once LIBRARY_PATH . '/pdf/fpdf.php';
     $pdf = new FPDF($pageLayout);
     $pdf->setTitle($report->getName());
     $pdf->AddPage();
     $pdf->SetFont('Arial', '', $fontSize);
     $pdf->Cell(80);
     $report_title = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($report->getName(), ENT_COMPAT));
     $pdf->Cell(30, 10, $report_title);
     $pdf->Ln(20);
     $colSizes = array();
     $maxValue = array();
     $fixed_col_sizes = array();
     foreach ($results['rows'] as $row) {
         $i = 0;
         foreach ($row as $k => $value) {
             if (!isset($maxValue[$i])) {
                 $maxValue[$i] = '';
             }
             if (strlen(strip_tags($value)) > strlen($maxValue[$i])) {
                 $maxValue[$i] = strip_tags($value);
             }
             $i++;
         }
     }
     $k = 0;
     foreach ($maxValue as $str) {
         $col_title_len = $pdf->GetStringWidth($results['columns'][$k]);
         $colMaxTextSize = max($pdf->GetStringWidth($str), $col_title_len);
         $db_col = $results['columns'][$k];
         $colType = array_var($types, array_var($results['db_columns'], $db_col, ''), '');
         if ($colType == DATA_TYPE_DATETIME && !($report->getObjectType() == 'ProjectEvents' && $results['db_columns'][$db_col] == 'start')) {
             $colMaxTextSize = $colMaxTextSize / 2;
             if ($colMaxTextSize < $col_title_len) {
                 $colMaxTextSize = $col_title_len;
             }
         }
         $fixed_col_sizes[$k] = $colMaxTextSize;
         $k++;
     }
     $fixed_col_sizes = self::fix_column_widths($pageLayout == 'P' ? 172 : 260, $fixed_col_sizes);
     $max_char_len = array();
     $i = 0;
     foreach ($results['columns'] as $col) {
         $colMaxTextSize = $fixed_col_sizes[$i];
         $colFontSize = $colMaxTextSize + 5;
         $colSizes[$i] = $colFontSize;
         $col_name = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($col, ENT_COMPAT));
         $pdf->Cell($colFontSize, 7, $col_name);
         $max_char_len[$i] = self::get_max_length_from_pdfsize($pdf, $colFontSize);
         $i++;
     }
     $lastColX = $pdf->GetX();
     $pdf->Ln();
     $pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
     foreach ($results['rows'] as $row) {
         $i = 0;
         $more_lines = array();
         $col_offsets = array();
         foreach ($row as $k => $value) {
             if ($k == 'link') {
                 $value = strip_tags($value);
                 $cell = $value;
             } else {
                 $cell = $this->format_value_to_print($k, $value, $types[$k], $report->getObjectType());
             }
             $cell = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($cell, ENT_COMPAT));
             $splitted = self::split_column_value($cell, $max_char_len[$i]);
             $cell = $splitted[0];
             if (count($splitted) > 1) {
                 array_shift($splitted);
                 $ml = 0;
                 foreach ($splitted as $sp_val) {
                     if (!isset($more_lines[$ml]) || !is_array($more_lines[$ml])) {
                         $more_lines[$ml] = array();
                     }
                     $more_lines[$ml][$i] = $sp_val;
                     $ml++;
                 }
                 $col_offsets[$i] = $pdf->x;
             }
             $pdf->Cell($colSizes[$i], 7, $cell);
             $i++;
         }
         foreach ($more_lines as $ml_values) {
             $pdf->Ln();
             foreach ($ml_values as $col_idx => $col_val) {
                 $pdf->SetX($col_offsets[$col_idx]);
                 $pdf->Cell($colSizes[$col_idx], 7, $col_val);
             }
         }
         $pdf->Ln();
         $pdf->SetDrawColor(220, 220, 220);
         $pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
         $pdf->SetDrawColor(0, 0, 0);
     }
     $filename = ROOT . "/tmp/" . gen_id() . ".pdf";
     $pdf->Output($filename, "F");
     download_file($filename, "application/pdf", $report->getName(), true);
     unlink($filename);
     die;
 }
Exemple #5
0
 function GetStringWidth($s)
 {
     if ($this->CurrentFont['type'] == 'Type0') {
         return $this->GetMBStringWidth($s);
     } else {
         return parent::GetStringWidth($s);
     }
 }
	<?php 
require_once 'fpdf16/fpdf.php';
// Dados para a tabela
$cabecalho = array('No.', 'Nome do Funcionário', 'Horas Trabalhadas', 'Horas Extras');
$dados = array(array(1, 'João Da Silva', 42, 2), array(2, 'Sebastião Alvarenga Rêgo', 40, 0), array(3, 'Joana D\'Arc Santana', 44, 4));
$pdf = new FPDF('P', 'cm', 'A4');
$pdf->AddPage();
$larguras = array();
$pdf->SetFont('Arial', 'BI', 12);
$pdf->SetFillColor(200, 200, 200);
// Cria o cabeçalho da tabela
foreach ($cabecalho as $i => $cab) {
    // armazena as larguras das células do cabeçalho
    $larguras[$i] = $pdf->GetStringWidth($cab) + 2;
    // imprime as células do cabeçalho
    $pdf->Cell($larguras[$i], 1, utf8_decode($cab), 1, 0, 'C', true);
}
$pdf->Ln();
$pdf->SetFont('Arial', '', 12);
// Cria as células da tabela
foreach ($dados as $e => $linha) {
    if ($e % 2 == 0) {
        $pdf->SetFillColor(230, 230, 230);
    } else {
        $pdf->SetFillColor(240, 240, 240);
    }
    foreach ($linha as $i => $celula) {
        // pega a largura do cabeçalho
        $pdf->Cell($larguras[$i], 1, utf8_decode($celula), 1, 0, 'C', true);
    }
    // quebra e manda para a próxima linha
 $people_query->execute();
 $people = $people_query->fetchAll(PDO::FETCH_ASSOC);
 $people_query->closeCursor();
 $newpage = intdiv($cell, $cells_per_page);
 if ($newpage > $page) {
     $pdf->AddPage();
     $page = $newpage;
 }
 $page_cell = $cell - $page * $cells_per_page;
 $row = $page_cell % $cells_per_col;
 $col = intdiv($page_cell, $cells_per_col);
 $name_string = create_name_string($people);
 $address = create_address($parties[$i]);
 // Figure out what the longest line is
 $pdf->SetFont("Astrud", "", NAME_SIZE_PTS);
 $name_width = $pdf->GetStringWidth($name_string);
 $pdf->SetFont("ufonts.com_century-gothic", "", ADDR_SIZE_PTS);
 $max_addr_width = $pdf->GetStringWidth($address[0]);
 for ($j = 1; $j < count($address); ++$j) {
     $addr_line_width = $pdf->GetStringWidth($address[$j]);
     if ($addr_line_width > $max_addr_width) {
         $max_addr_width = $addr_line_width;
     }
 }
 $max_line_width = max($name_width, $max_addr_width);
 // Center the longest line, and make everything else left justified to that
 $left_x = $start_x + $col * ($x_size + $row_sep) + ($x_size - $max_line_width) / 2;
 $pdf->SetLeftMargin($left_x);
 // Draw the name line
 $pdf->SetFont("Astrud", "", NAME_SIZE_PTS);
 //$name_width = $pdf->GetStringWidth($name_string);
Exemple #8
0
 function GetStringWidth($string)
 {
     $string = utf8_decode($string);
     return parent::GetStringWidth($string);
 }
 /**
  * Updates the PDF sizing information based on the current row of data
  *
  * @param  FPDF                 $newpdf      The PDF object we are creating
  * @param  stdClass             $datum       The current row of data
  * @param  array                $widths      Mapping of columns to widths
  * @param  array                $heights     Mapping of rows to heights
  * @param  id                   $row         Index of current row
  * @param  int array reference  $min_widths  Update with minimum column widths based on longest token
  */
 protected function update_pdf_sizings($newpdf, $datum, &$widths, &$heights, $row, &$min_widths)
 {
     if (!isset($heights[$row])) {
         $heights[$row] = 0;
     }
     //perform the calculation column-by-column
     foreach ($this->report->headers as $id => $header) {
         if (in_array(php_report::$EXPORT_FORMAT_PDF, $this->report->columnexportformats[$id])) {
             $effective_id = $this->report->get_object_index($id);
             if (isset($datum->{$effective_id})) {
                 $width = $newpdf->GetStringWidth(trim(strip_tags($datum->{$effective_id}))) + self::horizontal_buffer;
                 //update the width if applicable
                 if ($width > $widths[$id]) {
                     $lines = ceil($width / $widths[$id]);
                     $widths[$id] = $width;
                 } else {
                     $lines = 1;
                 }
                 $height = $lines * 0.2;
                 //update the height if applicable
                 if ($height > $heights[$row]) {
                     $heights[$row] = $height;
                 }
                 //update min width if appropriate
                 $min_width = $this->get_min_string_width($newpdf, trim(strip_tags($datum->{$effective_id})));
                 if ($min_width > $min_widths[$id]) {
                     $min_widths[$id] = $min_width;
                 }
             }
         }
     }
 }
 $pdf->Cell($avgw, $sh, 'Avg', 0, 1, 'C', 1);
 $y_coord += $sh;
 /** NOW FOR THE ASSIGNMENTS **/
 $pdf->SetFont('Times', '', 8);
 $pdf->SetXY($x_coord, $y_coord);
 $rcv = 1;
 foreach ($report['assignments'] as $grade) {
     if ($rcv % 2) {
         $pdf->SetFillColor(255, 255, 255);
     } else {
         $pdf->SetFillColor(238, 238, 238);
     }
     /** try to test for need to page break **/
     $lines = 1;
     if ($assignInfo['comment'] != '') {
         $lines += $pdf->GetStringWidth($assignInfo['comment']) / ($pw - $datew);
     }
     if ($y_coord + $sh * $lines > 10) {
         $pdf->AddPage();
         /** Page Title **/
         $pdf->SetTextColor(51, 102, 102);
         $pdf->SetFont('Times', 'B', $titlefs);
         $pdf->SetXY($lm, $tm);
         $pdf->Cell($headingw, $titleh, 'Questar III Student Progress Report (Contd.)', 0, 1, 'C', 0);
         $y_coord = $tm + $titleh;
         $pdf->SetXY($lm, $y_coord);
         $pdf->SetFont('Times', 'B', 10);
         $pdf->SetFillColor(192, 192, 192);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell($datew, $sh, 'Date', 0, 0, 'C', 1);
         $pdf->Cell($assignw, $sh, 'Assignment', 0, 0, 'C', 1);
	if( $entente_tel==='1' )
	{

		$grandeur = '';
		$text_tel = '';

		if ( $tel_image != '' )
		{

			$a = $pdf->GetX();
			$b = $pdf->GetY();
			$ima = '../../images/imabulle/'.$tel_image.'.jpg';
			$valeurima=redimensionne_image($ima, 15, 15);
			$pdf->Image($ima, $a, $b, $valeurima[0], $valeurima[1]);
			$text_tel = '      '.$gepiSchoolTel;
			$grandeur = $pdf->GetStringWidth($text_tel);
			$grandeur = $grandeur + 2;

		}
		if ( $tel_texte != '' and $tel_image === '' )
		{

			$text_tel = $tel_texte.''.$gepiSchoolTel;
			$grandeur = $pdf->GetStringWidth($text_tel);

		}

		$pdf->Cell($grandeur,5, $text_tel,0,$passealaligne,'');

	}
Exemple #12
0
$wMapaMax = 222;
$hMapaMax = 171;
$mapasize = getimagesize($pathMapa);
$wMapa = $mapasize[0];
$hMapa = $mapasize[1];
if ($wMapa / $wMapaMax > $hMapa / $hMapaMax) {
    $nW = $wMapaMax;
    $nH = $hMapa * $nW / $wMapa;
} else {
    $nH = $hMapaMax;
    $nW = $wMapa * $nH / $hMapa;
}
$pdf->Rect(3, 3, $nW + 69, 14, 'D');
//T&iacute;tulo
$pdf->SetFont('Arial', 'B', 18);
$xMsg = 292 / 2 - $pdf->GetStringWidth($titulo) / 2;
$pdf->Text($xMsg, 13, $titulo);
//208
$pdf->Rect(1, 1, 295, $nH + 30, 'D');
//Quadro
$pdf->Rect(3, 20, 65, $nH + 2, 'D');
//Legenda
$pdf->Rect(70, 20, $nW + 2, $nH + 2, 'D');
//Mapa
$pdf->Image($pathMapa, 71, 21, $nW, $nH);
$pdf->SetFont('Arial', '', 9);
//$pdf->Text(14,$nH-1,"Proje&ccedil;&atilde;o Geogr&aacute;ficas");
//$pdf->Text(14,$nH+3,"Sistema de Refer&ecirc;ncia:  SAD69");
$pdf->Image("../../imagens/i3geo1.jpg", 23, $nH + 5, 25);
$pdf->SetFont('Arial', '', 9);
$textMsg = "";
Exemple #13
0
 function text_width($size, $text)
 {
     if ($this->flash_font === NULL) {
         $this->error("No font specified.");
     }
     // end if
     parent::SetFont($this->flash_font, '', $size * $this->flash_font_size_conversion);
     return parent::GetStringWidth($text);
 }
Exemple #14
0
    /**
     * AGrega espacios en blancos segun el ancho en milimetros pasado como parametro
     */
    function agregarEspaciosEnBlancoOnTextIndent($text, $fontSize ,$mm_indent = 0) {
        if ($mm_indent == 0) return $text;
        
        // inicializo el FPDF para luego verificar el tamaño de la celda
        App::import('Vendor', 'fpdf/fpdf');
        $orientation = Configure::read('Fpdf.orientation');
        $unit = Configure::read('Fpdf.unit');
        $format = Configure::read('Fpdf.format');
        $fpdfAux = new FPDF();
        $fpdfAux->FPDF($orientation, $unit, $format);
        $fpdfAux->AddPage();

        $fpdfAux->SetFont(Configure::read('Fpdf.fontFamily'), '', $fontSize);
        
        $espacios = '';
        while ($mm_indent >=  $fpdfAux->GetStringWidth($espacios)){
            $espacios = $espacios.' ';
        }
        
        
        return $espacios.$text;
    }
Exemple #15
0
         $pdf->SetFillColor(192, 192, 192);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell($datew, $sh, 'Date', 0, 0, 'C', 1);
         $pdf->Cell($jobw, $sh, 'Job', 0, 0, 'C', 1);
         $pdf->Cell($typew, $sh, 'Type', 0, 0, 'L', 1);
         $pdf->Cell($contactw, $sh, 'Contact', 0, 0, 'C', 1);
         $pdf->Cell($locationw, $sh, 'Location', 0, 0, 'C', 1);
         $pdf->Cell($minutesw, $sh, 'minutes', 0, 1, 'C', 1);
         $y_coord += $sh;
         /** NOW FOR THE ASSIGNMENTS **/
         $pdf->SetFont('Times', '', 8);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY($x_coord, $y_coord);
         $rcv = 1;
     }
     $string_width = $pdf->GetStringWidth($job['job']);
     $lines = ceil($string_width / $jobw);
     $rowh = $lines * $sh;
     $rowh = ceil($rowh);
     $pdf->Cell($datew, $sh, $job['date'], 0, 0, 'C', 1);
     $pdf->MultiCell($jobw, $sh, $job['job'], 0, 'L', 1);
     $pdf->Cell($typew, $sh, $job['type'], 0, 0, 'L', 1);
     $pdf->Cell($contactw, $sh, $job['contact'], 0, 0, 'C', 1);
     $pdf->Cell($locationw, $sh, $job['location'], 0, 0, 'C', 1);
     $pdf->Cell($minutesw, $sh, $job['minutes'], 0, 1, 'C', 1);
     $minutes += $job['minutes'];
     $y_coord = $pdf->GetY();
     $rcv++;
 }
 /** end if there are jobss **/
 $x_coord = $lm;
     semi_log(2);
     break;
     // Génération papier semi-log a 5 modules
 // Génération papier semi-log a 5 modules
 case 14:
     semi_log(5);
     break;
     // En cas de problème, affichage d'une page d'erreur
 // En cas de problème, affichage d'une page d'erreur
 default:
     $pdf->AddPage();
     $pdf->Image('images/logo_erreur.png', 30, 30, 20);
     $pdf->Image('images/logo_erreur.png', 160, 30, 20);
     $pdf->SetFont('Arial', 'B', 48);
     $pdf->SetTextColor(255, 0, 0);
     $largeur = $pdf->GetStringWidth('ERREUR');
     $pos = 105 - $largeur / 2;
     $pdf->Text($pos, 45, 'ERREUR');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('Arial', '', 12);
     $largeur = $pdf->GetStringWidth($date);
     $pos = 105 - $largeur / 2;
     $pdf->Text($pos, 50, $date);
     $pdf->Image('images/logo_info.png', 30, 60, 20);
     $pdf->Image('images/logo_info.png', 160, 60, 20);
     $pdf->SetTextColor(0, 0, 255);
     $largeur = $pdf->GetStringWidth('Le papier que vous avez sélectionné n\'existe pas...');
     $pos = 105 - $largeur / 2;
     $pdf->Text($pos, 70, 'Le papier que vous avez sélectionné n\'existe pas...');
     $largeur = $pdf->GetStringWidth('Imprimez ce document, puis déposez-le dans mon casier.');
     $pos = 105 - $largeur / 2;
function creation_resume($animal_id, $info_analyse, $info_radio, $info_formulaire, $variable)
{
    $filename = '../sauvegarde/animaux/' . $animal_id;
    if (!file_exists($filename)) {
        if (!mkdir($filename, 0755, true)) {
            die('Echec lors de la création des répertoires...');
        }
    }
    $info_veto = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login'])));
    if (empty($info_veto)) {
        throw new Exception("Erreur dans la recherche des informations sur le vétérinaire");
    } else {
        $info_veto = json_decode($info_veto, true);
    }
    if ($_SESSION['login'] != $_SESSION['login2']) {
        $info_veto2 = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login2'])));
        if (empty($info_veto2)) {
            throw new Exception("Erreur dans la recherche des informations sur le vétérinaire qui a réalisé la consultation");
        } else {
            $info_veto2 = json_decode($info_veto2, true);
        }
    }
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->Image('../image/logo/essai1.jpg', 10, 6, 30);
    $pdf->SetFont('Times', '', 18);
    $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
    $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
    $pdf->SetX((210 - $w) / 2);
    $pdf->Cell($w, 7, $titre3, 0, 'C');
    $pdf->Ln();
    $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
    $pdf->SetX((210 - $w) / 2);
    $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
    $pdf->Ln();
    $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
    $pdf->SetX((210 - $w) / 2);
    $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
    $pdf->Ln();
    $pdf->SetFont('Times', '', 12);
    $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
    $pdf->SetX((210 - $w) / 2);
    $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
    $pdf->Ln(20);
    $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
    $pdf->SetFont('Times', 'B', 12);
    $pdf->MultiCell(190, 7, requetemysql::gestion_string_maj("Résumé de la consultation du " . $info_formulaire['date_consultation'] . ", concernant :" . $_POST['caracteristique']), '0', 'L');
    $pdf->SetFont('Times', '', 12);
    if ($_SESSION['login'] != $_SESSION['login2']) {
        $pdf->MultiCell(190, 7, requetemysql::gestion_string_maj("Cette consultation a été réalisée par " . $info_veto2[0]['nom_vet'] . ", exerçant à :" . $info_veto2[0]['adresse'] . " " . $info_veto2[0]['code'] . " " . $info_veto2[0]['commune'] . ". Téléphone :" . $info_veto2[0]['tel']), '0', 'L');
        $pdf->Ln();
    }
    $pdf->SetFont('Times', '', 14);
    $pdf->SetFillColor(153, 153, 153);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->SetDrawColor(153, 153, 153);
    $pdf->SetLineWidth(0.3);
    $pdf->MultiCell(190, 10, requetemysql::gestion_string_maj("Motif de consultation :" . $info_formulaire['barre_resume']), '0', 'L', true);
    $pdf->Ln();
    $pdf->SetFont('Times', '', 12);
    $pdf->MultiCell(190, 5, requetemysql::gestion_string_maj("Détail :" . $info_formulaire['clinique']), 0, 'L');
    $pdf->Ln(15);
    $pdf->Cell(50, 20, utf8_decode("signature du vétérinaire :"), 0, 0, false);
    if (count($info_analyse) > 0) {
        $pdf->AddPage();
        $pdf->Image('../image/logo/essai1.jpg', 10, 6, 30);
        $pdf->SetFont('Times', '', 18);
        $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
        $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, $titre3, 0, 'C');
        $pdf->Ln();
        $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
        $pdf->Ln();
        $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
        $pdf->Ln();
        $pdf->SetFont('Times', '', 12);
        $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
        $pdf->Ln(20);
        $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
        $pdf->SetFont('Times', 'B', 12);
        $pdf->MultiCell(190, 7, requetemysql::gestion_string_maj("Résultat d'analyse du " . $info_formulaire['date_consultation'] . ", concernant :" . $_POST['caracteristique']), '0', 'L');
        $pdf->SetFont('Times', '', 12);
        if ($_SESSION['login'] != $_SESSION['login2']) {
            $pdf->MultiCell(190, 7, requetemysql::gestion_string_maj("Ces analyses ont été réalisées par " . $info_veto2[0]['nom_vet'] . ", exerçant à :" . $info_veto2[0]['adresse'] . " " . $info_veto2[0]['code'] . " " . $info_veto2[0]['commune'] . ". Téléphone :" . $info_veto2[0]['tel']), '0', 'L');
        }
        $pdf->Ln();
        // Largeurs des colonnes
        $w = array(190 / 4, 190 / 6, 190 / 6, 190 / 4, 190 / 6);
        $header = array(utf8_decode('Référence'), utf8_decode('Résultat'), utf8_decode('Unité'), utf8_decode('Méthode'), utf8_decode("date d'analyse"));
        // En-tête
        for ($i = 0; $i < count($header); $i++) {
            $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
        }
        $pdf->Ln();
        // Données
        foreach ($info_analyse as $row) {
            $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj($row['nom']), 'LR', 0, 'C');
            $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row['resultat']), 'LR', 0, 'R');
            $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm($row['unite']), 'LR', 0, 'C');
            $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm($row['methode']), 'LR', 0, 'C');
            $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm($row['ma_date']), 'LR', 0, 'C');
            $pdf->Ln();
        }
        // Trait de terminaison
        $pdf->Cell(array_sum($w), 0, '', 'T');
        $pdf->Ln(8);
        $pdf->Cell(50, 20, utf8_decode("Commentaire :"), 'LTB', 0, false);
        $pdf->MultiCell(0, 20, requetemysql::gestion_string_maj($info_formulaire['commentaire']), 'TRB', 'L', false);
    }
    if (count($info_radio) > 0 || $info_formulaire['result_radio'] != '') {
        $pdf->AddPage();
        $pdf->Image('../image/logo/essai1.jpg', 10, 6, 30);
        $pdf->SetFont('Times', '', 18);
        $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
        $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, $titre3, 0, 'C');
        $pdf->Ln();
        $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
        $pdf->Ln();
        $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
        $pdf->Ln();
        $pdf->SetFont('Times', '', 12);
        $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
        $pdf->SetX((210 - $w) / 2);
        $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
        $pdf->Ln(20);
        $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
        $pdf->SetFont('Times', 'B', 12);
        $pdf->MultiCell(190, 7, requetemysql::gestion_string_maj("Compte-rendu de l'examen radiologique du " . $info_formulaire['date_consultation'] . ", concernant :" . $_POST['caracteristique']), '0', 'L');
        $pdf->SetFont('Times', '', 12);
        if ($_SESSION['login'] != $_SESSION['login2']) {
            $pdf->MultiCell(190, 7, requetemysql::gestion_string_maj("Ces radios ont été réalisées par " . $info_veto2[0]['nom_vet'] . ", exerçant à :" . $info_veto2[0]['adresse'] . " " . $info_veto2[0]['code'] . " " . $info_veto2[0]['commune'] . ". Téléphone :" . $info_veto2[0]['tel']), '0', 'L');
        }
        $pdf->Ln();
        // Largeurs des colonnes
        $w = array(190 / 4, 190 / 4, 190 / 4, 190 / 4);
        $header = array(utf8_decode('Personnel exposé aux RX'), utf8_decode('constantes'), utf8_decode('date'), utf8_decode('Zone radiographiée'));
        // En-tête
        for ($i = 0; $i < count($header); $i++) {
            $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
        }
        $pdf->Ln();
        // Données
        foreach ($info_radio as $row) {
            $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj($row['perso']), 'LR', 0, 'R');
            $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row['expo']), 'LR', 0, 'R');
            $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm($row['ma_date']), 'LR', 0, 'C');
            $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm($row['zone']), 'LR', 0, 'C');
            $pdf->Ln();
        }
        // Trait de terminaison
        $pdf->Cell(array_sum($w), 0, '', 'T');
        $pdf->Ln(4);
        $pdf->MultiCell(0, 10, utf8_decode("Résultat de la lecture de cliché :"), 'LTRB', 'C', false);
        $pdf->Ln(4);
        $pdf->Write(5, requetemysql::gestion_string_maj($info_formulaire['result_radio']));
    }
    $mon_url = '../sauvegarde/animaux/' . $_POST['animal_id'] . '/resume_consult_' . $variable . '.pdf';
    $pdf->Output($mon_url, F);
    return $mon_url;
}
Exemple #18
0
$pdf = new FPDF();
for ($i = 0; $i < $size; $i++) {
    switch ($option) {
        default:
            redirect_header("javascript:history.go(-1)", 2, _PM_REDNON);
            break;
        case "pdf_messages":
            $pm_handler =& xoops_gethandler('priv_msgs');
            $pm =& $pm_handler->get($msg_id[$i]);
            $pdf_data['title'] = utf8_decode(Chars($pm->getVar('subject')));
            $pdf_data['content'] = utf8_decode(Chars($pm->getVar('msg_text')));
            $pdf_data['date'] = formatTimestamp($pm->getVar('msg_time'));
            $pdf_data['author'] = XoopsUser::getUnameFromId($pm->getVar('from_userid'));
            $pdf->AddPage();
            $pdf->SetFont('Arial', 'B', 15);
            $w = $pdf->GetStringWidth($pdf_data['title']) + 6;
            $pdf->SetX((210 - $w) / 2);
            $pdf->SetDrawColor(204, 204, 204);
            $pdf->SetFillColor(0, 0, 0);
            $pdf->SetLineWidth(0.2);
            $pdf->SetTextColor(255, 255, 255);
            $pdf->Cell($w, 8, Chars($pdf_data['title']), 1, 1, 'C', true);
            $pdf->Ln(6);
            // date
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetTextColor(0, 0, 0);
            $pdf->SetFillColor(255, 255, 255);
            $pdf->MultiCell(40, 8, chars(_MP_TRI_DATE) . ': ' . $pdf_data['date'], 1, 1, 'L', true);
            $pdf->Ln(6);
            $pdf->SetFont('Arial', '', 8);
            $pdf->SetFillColor(239, 239, 239);
Exemple #19
0
     throw new Exception("Erreur dans la recherche des informations sur le vétérinaire");
 } else {
     $info_client = json_decode($info_client, true);
 }
 if (!file_exists($filename)) {
     if (!mkdir($filename, 0755, true)) {
         die('Echec lors de la création des répertoires...');
     }
 }
 $pdf = new FPDF();
 $pdf->AliasNbPages();
 $pdf->AddPage();
 $pdf->Image('../image/logo/essai1.jpg', 10, 6, 30);
 $pdf->SetFont('Times', '', 18);
 $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
 $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, $titre3, 0, 'C');
 $pdf->Ln();
 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
 $pdf->Ln();
 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
 $pdf->Ln();
 $pdf->SetFont('Times', '', 12);
 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
 /**
  * Get the data needed for a downloadable version of the report (all data,
  * no paging necessary) and format it accordingly for the download file
  * type.
  *
  * NOTE: It is expected that the valid format types will be overridden in
  * an extended report class as the array is empty by default.
  *
  * @param string $format A valid format type.
  */
 function download($format)
 {
     global $CFG;
     $output = '';
     if (empty($this->data)) {
         return $output;
     }
     $filename = !empty($this->title) ? $this->title : 'report_download';
     switch ($format) {
         case 'csv':
             $filename .= '.csv';
             header("Content-Transfer-Encoding: ascii");
             header("Content-Disposition: attachment; filename={$filename}");
             header("Content-Type: text/comma-separated-values");
             $row = array();
             foreach ($this->headers as $header) {
                 $row[] = $this->csv_escape_string(strip_tags($header));
             }
             echo implode(',', $row) . "\n";
             foreach ($this->data as $datum) {
                 if (!is_object($datum)) {
                     continue;
                 }
                 $row = array();
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $row[] = $this->csv_escape_string($datum->{$id});
                     } else {
                         $row[] = '""';
                     }
                 }
                 echo implode(',', $row) . "\n";
             }
             break;
         case 'excel':
             require_once $CFG->libdir . '/excellib.class.php';
             $filename .= '.xls';
             /// Creating a workbook
             $workbook = new MoodleExcelWorkbook('-');
             /// Sending HTTP headers
             $workbook->send($filename);
             /// Creating the first worksheet
             $sheettitle = get_string('studentprogress', 'reportstudentprogress');
             $myxls =& $workbook->add_worksheet($sheettitle);
             /// Format types
             $format =& $workbook->add_format();
             $format->set_bold(0);
             $formatbc =& $workbook->add_format();
             $formatbc->set_bold(1);
             $formatbc->set_align('center');
             $formatb =& $workbook->add_format();
             $formatb->set_bold(1);
             $formaty =& $workbook->add_format();
             $formaty->set_bg_color('yellow');
             $formatc =& $workbook->add_format();
             $formatc->set_align('center');
             $formatr =& $workbook->add_format();
             $formatr->set_bold(1);
             $formatr->set_color('red');
             $formatr->set_align('center');
             $formatg =& $workbook->add_format();
             $formatg->set_bold(1);
             $formatg->set_color('green');
             $formatg->set_align('center');
             $rownum = 0;
             $colnum = 0;
             foreach ($this->headers as $header) {
                 $myxls->write($rownum, $colnum++, $header, $formatbc);
             }
             foreach ($this->data as $datum) {
                 if (!is_object($datum)) {
                     continue;
                 }
                 $rownum++;
                 $colnum = 0;
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $myxls->write($rownum, $colnum++, $datum->{$id}, $format);
                     } else {
                         $myxls->write($rownum, $colnum++, '', $format);
                     }
                 }
             }
             $workbook->close();
             break;
         case 'pdf':
             require_once $CFG->libdir . '/fpdf/fpdf.php';
             $filename .= '.pdf';
             $newpdf = new FPDF('L', 'in', 'letter');
             $marginx = 0.75;
             $marginy = 0.75;
             $newpdf->setMargins($marginx, $marginy);
             $newpdf->SetFont('Arial', '', 9);
             $newpdf->AddPage();
             $newpdf->SetFont('Arial', '', 16);
             $newpdf->MultiCell(0, 0.2, $this->title, 0, 'C');
             $newpdf->Ln(0.2);
             $newpdf->SetFont('Arial', '', 8);
             $newpdf->SetFillColor(225, 225, 225);
             $heights = array();
             $widths = array();
             $hmap = array();
             $rownum = 0;
             /// PASS 1 - Calculate sizes.
             foreach ($this->headers as $id => $header) {
                 $widths[$id] = $newpdf->GetStringWidth($header) + 0.2;
             }
             $row = 0;
             foreach ($this->data as $datum) {
                 if (!isset($heights[$row])) {
                     $heights[$row] = 0;
                 }
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $width = $newpdf->GetStringWidth($datum->{$id}) + 0.2;
                         if ($width > $widths[$id]) {
                             $lines = ceil($width / $widths[$id]);
                             $widths[$id] = $width;
                         } else {
                             $lines = 1;
                         }
                         $height = $lines * 0.2;
                         if ($height > $heights[$row]) {
                             $heights[$row] = $height;
                         }
                     }
                 }
                 $row++;
             }
             /// Calculate the width of the table...
             $twidth = 0;
             foreach ($widths as $width) {
                 $twidth += $width;
             }
             /// Readjust the left margin according to the total width...
             $marginx = (11.0 - $twidth) / 2.0;
             $newpdf->setMargins($marginx, $marginy);
             foreach ($this->headers as $id => $header) {
                 $text = str_replace(' ', "\n", $header);
                 $newpdf->Cell($widths[$id], 0.2, "{$text}", 1, 0, 'C', 1);
             }
             $newpdf->Ln();
             $row = 0;
             foreach ($this->data as $datum) {
                 if (is_array($datum) && strtolower($datum[0]) == 'hr') {
                     $curx = $newpdf->GetX();
                     $cury = $newpdf->GetY() + 0.1;
                     $endx = 0;
                     $endy = $cury;
                     foreach ($widths as $width) {
                         $endx += $width;
                     }
                     $newpdf->Line($curx, $cury, $endx, $endy);
                     $newpdf->SetX($curx + 0.1);
                 } else {
                     foreach ($this->headers as $id => $header) {
                         $text = '';
                         if (isset($datum->{$id})) {
                             $text = $datum->{$id};
                         }
                         $newpdf->Cell($widths[$id], $heights[$row], $text, 0, 0, 'C', 0);
                     }
                 }
                 $newpdf->Ln();
                 $row++;
             }
             $newpdf->Output($filename, 'I');
             break;
         default:
             return $output;
             break;
     }
 }
 /**
  * Render a single-line text field to the PDF
  *
  * @since 1.0
  * @param FPDF $fpdf fpdf library object
  * @param string $field_name the field name
  * @param mixed $value string or int value to display
  * @param int $show_border a debugging/helper option to display a border
  *        around the position for this field
  * @param string $align optional text alignment.  Defaults to 'L' for left-justified, but can also be 'R' for right-justified or 'C' for center-justified
  */
 public function text_field($fpdf, $field_name, $value, $show_border, $align = 'L')
 {
     if ($this->get_field_position($field_name) && $value) {
         $font = $this->get_field_font($field_name);
         // get the field position
         list($x, $y, $w, $h) = array_map(array($this, 'convert_pixels_to_points'), array_values($this->get_field_position($field_name)));
         // font color
         $font['color'] = $this->hex2rgb($font['color']);
         $fpdf->SetTextColor($font['color'][0], $font['color'][1], $font['color'][2]);
         // set the field text styling
         $font_path = "/" . strtolower($font['family'] . $font['style'] . ".php");
         $fpdf->AddFont($font['family'], $font['style'], $font_path);
         $fpdf->SetFont($font['family'], $font['style'], $font['size']);
         // show a border for debugging purposes
         if ($show_border) {
             $fpdf->setXY($x, $y);
             $fpdf->Cell($w, $h, '', 1);
         }
         // align the text to the bottom edge of the cell by translating as needed
         $y = $font['size'] > $h ? $y - ($font['size'] - $h) / 2 : $y + ($h - $font['size']) / 2;
         // handle right/center justification, it's left-justified by default so nothing to do in that case
         if ('R' == $align) {
             $x = max(0, $x + ($w - $fpdf->GetStringWidth($value)));
         } elseif ('C' == $align) {
             $x = max(0, $x + ($w - $fpdf->GetStringWidth($value)) / 2);
         }
         $fpdf->setXY($x, $y);
         // and write out the value
         $fpdf->Cell($w, $h, utf8_decode($value));
         // can try iconv('UTF-8', 'windows-1252', $value); if this doesn't work correctly for accents
     }
 }
Exemple #22
0
 $mon_animal = $_POST['animal'];
 $medoc = $_POST['medoc'];
 $commentaire = $_POST['commentaire'];
 $horaires = $_POST['horaires'];
 $competences = $_POST['competences'];
 if (!file_exists($filename)) {
     if (!mkdir($filename, 0755, true)) {
         die('Echec lors de la création des répertoires...');
     }
 }
 $pdf = new FPDF();
 $pdf->AddPage();
 $pdf->SetFont('Times', '', 22);
 $pdf->Image('../image/logo/essai1.jpg', 10, 10, 50, 40);
 $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
 $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, $titre3, 0, 'C');
 $pdf->SetFont('Times', '', 18);
 $pdf->Ln();
 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
 $pdf->Ln();
 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
 $pdf->SetX((210 - $w) / 2);
 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
 $pdf->Ln(30);
 $pdf->SetFont('Times', '', 12);
 $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
 $pdf->Ln();
Exemple #23
0
 require_once '../includes/fpdf.php';
 $pdf = new FPDF('L', 'cm', array(7.7, 15.9));
 $pdf->SetAuthor("*****@*****.**");
 $pdf->SetSubject("Cheque");
 $pdf->SetTitle("Cheque");
 $pdf->SetCreator("Imran Zahid");
 $pdf->AddPage();
 $pdf->SetFont('Arial', '', 12);
 $amt = explode(' ', convertCurrency($_GET['amount']) . " Only.");
 $str1 = "";
 $sep = "";
 $w = 0;
 $counter = 0;
 do {
     $temp = $str1 . $sep . $amt[$counter];
     $w = $pdf->GetStringWidth($temp);
     if ($w < $MAX_LIMIT) {
         $str1 .= $sep . $amt[$counter];
         $sep = " ";
         $counter++;
     }
     if ($counter > count($amt)) {
         break;
     }
 } while ($w < $MAX_LIMIT);
 $str2 = "";
 $sep = "";
 for ($i = $counter; $i < count($amt); $i++) {
     $str2 .= $sep . $amt[$i];
     $w = $pdf->GetStringWidth($str2);
     $sep = " ";
 /**
  * Meto lo que venga en el string 'field_name' en distintos 'renglones'
  * lo que hace esta funcion es ir agregando palabra a palabra. opara asegurarse que
  * siempre entraran palabras completas y nunca quedaran cortadas.
  *
  * @param array $options
  *                  array  'renglones' => Son los field_coordenates name, en ellos se imprimiran el valor pasado
  *                  string 'field_name'=> Texto a imprimir en esos renglones
  */
 function meterNombreCompletoEnVariosRenglones($options)
 {
     if (empty($options['field_name'])) {
         return -2;
     }
     if (empty($options['renglones'])) {
         $this->log("en metodo meterNombreCompletoEnVariosRenglones no se pasaron los paramentros correctamente");
         debug("no se pasaron los parametros correctamente");
         return -1;
     }
     // preparo el texto en array para recorrerlo y calcular su tamaño
     $vec = explode(" ", $options['field_name']);
     //limpio caracteres nulos, espacios en blanco
     $newVec = array();
     foreach ($vec as $v) {
         if (!empty($v)) {
             $newVec[] = $v;
         }
     }
     $vec = $newVec;
     // inicializo el FPDF para luego verificar el tamaño de la celda
     App::import('Vendor', 'fpdf/fpdf');
     $orientation = Configure::read('Fpdf.orientation');
     $unit = Configure::read('Fpdf.unit');
     $format = Configure::read('Fpdf.format');
     $fpdfAux = new FPDF();
     $fpdfAux->FPDF($orientation, $unit, $format);
     $fpdfAux->AddPage();
     $field_coord =& ClassRegistry::init('FieldCoordenate');
     foreach ($options['renglones'] as $r) {
         $coordenada = $field_coord->find('first', array('conditions' => array('FieldCoordenate.name' => $r, 'FieldCoordenate.field_creator_id' => $this->getFieldCreatorId())));
         $texto = '';
         // Fuente
         $fpdfAux->SetFont(Configure::read('Fpdf.fontFamily'), '', $coordenada['FieldCoordenate']['font_size']);
         // si oes multicell entonces meto todo el string de una saque eso lo maneja el propio metodo Multicell
         if ($coordenada['FieldCoordenate']['field_type_id'] == 3) {
             // Multicell
             $texto = implode(" ", $vec);
             $this->populateFieldWithValue($coordenada['FieldCoordenate']['id'], $texto);
             return 1;
         }
         // como no es multicelda debo agregar palabra por palabra
         while ($palabra = array_shift($vec)) {
             if (strtoupper($palabra) == 'CUIT' || strtoupper($palabra) == 'CUIL') {
                 $palabra .= " " . array_shift($vec);
             }
             // si el renglon tiene ancho infinito, o sin límite
             if ($coordenada['FieldCoordenate']['w'] == 0) {
                 array_unshift($vec, $palabra);
                 $texto = implode(" ", $vec);
                 $vec = array();
                 // vacio el array
             }
             // si la palabra entra.. la concateno el texto
             if ($coordenada['FieldCoordenate']['w'] >= $fpdfAux->GetStringWidth($texto . " " . $palabra)) {
                 $texto .= " " . $palabra;
             } else {
                 // si la palabra no entraba, la vuelvo a meter al array
                 array_unshift($vec, $palabra);
                 break;
             }
         }
         $this->populateFieldWithValue($coordenada['FieldCoordenate']['id'], $texto);
         $texto = '';
         // lo vuelvo a inicializar
         if (count($vec) == 0) {
             break;
         }
         // salgo del For renglones
     }
     return 2;
 }
Exemple #25
0
 /**
  * print_result4
  * print all the jobs realized by member since reference date selected in the second part (start date to share job between member)
  *
  * @param array $arr :
  * @param array $arr['team'] team with param (login, nom, adresse, code, commune, tel1, tel2, mail)
  * @param array $arr['team2'] team2 with param (login, total_job, total_jobv2, liste_job)
  * @param date $arr['date_ref'] format DD/MM/YYYY date selected to begin share job between member
  * @param string $arr['date_debut'] date of the begin of the selected month format : DD/MM/YYYY
  * @param string $arr['date_fin'] date of the end of the selected month format : DD/MM/YYYY
  * @param array $arr['agenda'] array of schedule for the month sort by job and by login
  * @return json json of ok
  */
 public static function print_result4($arr)
 {
     try {
         require 'fpdf/fpdf.php';
         require 'fpdi/fpdi.php';
         $filename = 'planning/';
         if (!file_exists($filename)) {
             if (!mkdir($filename, 0755, true)) {
                 die('Echec lors de la création des répertoires...');
             }
         }
         if ($arr['cas'] == 1) {
             $pdf = new FPDF();
         }
         $intersect = array_uintersect($arr['team'], $arr['team2'], 'compareDeepValue');
         if (isset($_SESSION['login2'])) {
             $info_veto = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login'])));
             if (empty($info_veto)) {
                 throw new Exception("Erreur dans la recherche des informations sur le vétérinaire");
             } else {
                 $info_veto = json_decode($info_veto, true);
             }
         }
         $transformation_object = array_map(function ($e) {
             return is_object($e) ? $e->login : $e['login'];
         }, $arr['team2']);
         //			var_error_log("liste_pointv2");
         //			var_error_log($transformation_object);
         foreach ($intersect as $info_veto2) {
             if ($arr['cas'] == 2) {
                 $pdf = new FPDF();
             }
             $mon_index = array_search($info_veto2->login, $transformation_object);
             var_error_log($mon_index);
             $pdf->AddPage();
             $pdf->Image('../images/logo/essai1.jpg', 10, 6, 30);
             if (isset($_SESSION['login2'])) {
                 $pdf->SetFont('Times', '', 18);
                 $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom'])));
                 $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, $titre3, 0, 'C');
                 $pdf->Ln();
                 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C');
                 $pdf->Ln();
                 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C');
                 $pdf->Ln();
                 $pdf->SetFont('Times', '', 12);
                 $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6;
                 $pdf->SetX((210 - $w) / 2);
                 $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C');
                 $pdf->Ln(15);
             }
             $pdf->Cell(90);
             $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj($info_veto2->nom) . "\n" . requetemysql::gestion_string_norm($info_veto2->adresse) . "\n" . requetemysql::gestion_string_norm($info_veto2->code) . ' ' . requetemysql::gestion_string_norm($info_veto2->commune), 0, 'C');
             $pdf->Ln(25);
             $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
             if (isset($_SESSION['login2'])) {
                 $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . stripslashes(ucfirst($info_veto[0]['nom']))), 0, 'L');
             } else {
                 $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT23), 0, 'L');
             }
             $pdf->SetFont('Times', '', 18);
             $pdf->SetFillColor(153, 153, 153);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetDrawColor(153, 153, 153);
             $pdf->SetLineWidth(0.3);
             $pdf->SetFont('', 'B');
             $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT24 . requetemysql::gestion_string_maj(htmlentities($info_veto2->login)) . " sur la période du :" . requetemysql::gestion_string_norm($arr['date_ref']) . " au " . requetemysql::gestion_string_norm($arr['date_fin'])), 0, '', true);
             // Largeurs des colonnes
             $w = array(190 / 6, 190 / 6, 190 / 6, 190 / 2);
             $header = array(utf8_decode(TXT_CHARGEMENT_EXPORT26), utf8_decode(TXT_CHARGEMENT_EXPORT27) . " " . requetemysql::gestion_string_norm($arr['date_ref']) . "-" . requetemysql::gestion_string_norm($arr['date_debut']), utf8_decode(TXT_CHARGEMENT_EXPORT27) . " " . requetemysql::gestion_string_norm($arr['date_ref']) . "-" . requetemysql::gestion_string_norm($arr['date_fin']), utf8_decode(TXT_CHARGEMENT_EXPORT28));
             // Données
             $pdf->SetFont('Times', '', 8);
             // En-tête
             for ($i = 0; $i < count($header); $i++) {
                 $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
             }
             $pdf->Ln();
             foreach ($arr['team2'][$mon_index]->total_job as $row) {
                 foreach ($row as $k => $v) {
                     $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj($k), 1, 0, 'C');
                     $pdf->Cell($w[1], 6, requetemysql::gestion_string_maj($v), 1, 0, 'C');
                     foreach ($arr['team2'][$mon_index]->total_jobv2 as $row2) {
                         foreach ($row2 as $k2 => $v2) {
                             if ($k2 == $k) {
                                 $pdf->Cell($w[2], 6, requetemysql::gestion_string_maj($v2), 1, 0, 'C');
                             }
                         }
                     }
                     $retour1 = true;
                     foreach ($arr['team2'][$mon_index]->liste_job as $row3) {
                         foreach ($row3 as $k3 => $v3) {
                             if ($k3 == $k) {
                                 $retour1 = false;
                                 $pdf->MultiCell($w[3], 6, requetemysql::gestion_string_maj(implode(",", $v3)) . " " . $arr['agenda'][$k][$info_veto2->login], 1, 'L', false);
                             }
                         }
                     }
                     if ($retour1) {
                         $pdf->Ln();
                     }
                 }
             }
             // Trait de terminaison
             $pdf->Cell(array_sum($w), 0, '', 'T');
             $pdf->Ln(20);
             if ($arr['cas'] == 2) {
                 $mon_url = $filename . 'resume_activite_' . requetemysql::gestion_string_maj(htmlentities($info_veto2->login)) . '_' . uniqid() . '.pdf';
                 //$pdf->Output($mon_url, F);
                 $pdf->Output('../' . $mon_url, F);
                 $filename = $mon_url;
                 $files_name = explode("/", $filename);
                 if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}\$#", $info_veto2->mail)) {
                     $passage_ligne = "\r\n";
                 } else {
                     $passage_ligne = "\n";
                 }
                 //=====Déclaration des messages au format texte et au format HTML.
                 $message_txt = TXT_CHARGEMENT_EXPORT32 . $info_veto2->nom . TXT_CHARGEMENT_EXPORT33 . stripslashes(ucfirst($info_veto[0]['nom'])) . TXT_CHARGEMENT_EXPORT34 . requetemysql::gestion_string_norm($arr['date_ref']) . " - " . requetemysql::gestion_string_norm($arr['date_fin']);
                 $message_txt .= TXT_CHARGEMENT_EXPORT35;
                 $message_txt = utf8_decode($message_txt);
                 $message_html = TXT_CHARGEMENT_EXPORT36 . $info_veto2->nom . TXT_CHARGEMENT_EXPORT37 . stripslashes(ucfirst($info_veto[0]['nom'])) . TXT_CHARGEMENT_EXPORT38 . requetemysql::gestion_string_norm($arr['date_ref']) . " - " . requetemysql::gestion_string_norm($arr['date_fin']) . " : </p>";
                 $message_html .= TXT_CHARGEMENT_EXPORT39;
                 $message_html = utf8_decode($message_html);
                 //=====Lecture et mise en forme de la pièce jointe analyse.
                 $fichier = fopen('../' . $filename, "r");
                 $attachement = fread($fichier, filesize('../' . $filename));
                 $attachement = chunk_split(base64_encode($attachement));
                 fclose($fichier);
                 //==========
                 //==========
                 //=====Création de la boundary
                 $boundary = "-----=" . md5(rand());
                 $boundary_alt = "-----=" . md5(rand());
                 //==========
                 //=====Définition du sujet.
                 $sujet = TXT_CHARGEMENT_EXPORT40;
                 //=========
                 //=====Création du header de l'e-mail
                 $header = "From: \"" . NOMMAILSERVEUR . "\"<" . MAILSERVEUR . ">" . $passage_ligne;
                 $header .= "Reply-to: \"" . NOMMAILSERVEUR . "\" <" . MAILSERVEUR . ">" . $passage_ligne;
                 $header .= "Bcc: \"archives urgences vet\" <*****@*****.**>" . $passage_ligne;
                 $header .= "MIME-Version: 1.0" . $passage_ligne;
                 $header .= "Content-Type:  multipart/mixed;" . $passage_ligne . " boundary=\"{$boundary}\"" . $passage_ligne;
                 //=====Création du message.
                 $message = $passage_ligne . "--" . $boundary . $passage_ligne;
                 $message .= "Content-Type: multipart/alternative;" . $passage_ligne . " boundary=\"{$boundary_alt}\"" . $passage_ligne;
                 $message .= $passage_ligne . "--" . $boundary_alt . $passage_ligne;
                 //=====Ajout du message au format texte.
                 $message .= "Content-Type: text/plain; charset=\"ISO-8859-1\"" . $passage_ligne;
                 $message .= "Content-Transfer-Encoding: 8bit" . $passage_ligne;
                 $message .= $passage_ligne . $message_txt . $passage_ligne;
                 //==========
                 $message .= $passage_ligne . "--" . $boundary_alt . $passage_ligne;
                 //=====Ajout du message au format HTML
                 $message .= "Content-Type: text/html; charset=\"ISO-8859-1\"" . $passage_ligne;
                 $message .= "Content-Transfer-Encoding: 8bit" . $passage_ligne;
                 $message .= $passage_ligne . $message_html . $passage_ligne;
                 //==========
                 $message .= $passage_ligne . "--" . $boundary_alt . "--" . $passage_ligne;
                 //==========
                 $message .= $passage_ligne . "--" . $boundary . $passage_ligne;
                 //=====Ajout de la pièce jointe.
                 $message .= "Content-Type: application/pdf; name=\"" . $files_name[count($files_name) - 1] . "\"" . $passage_ligne;
                 $message .= "Content-Transfer-Encoding: base64" . $passage_ligne;
                 $message .= "Content-Disposition: attachment; filename=\"" . $files_name[count($files_name) - 1] . "\"" . $passage_ligne;
                 $message .= $passage_ligne . $attachement . $passage_ligne . $passage_ligne;
                 //==========
                 $message .= $passage_ligne . "--" . $boundary . "--" . $passage_ligne;
                 //=====Envoi de l'e-mail.
                 mail($info_veto2->mail, $sujet, $message, $header);
                 //==========
                 usleep(100000);
             }
         }
         if ($arr['cas'] == 1) {
             $mon_url = $filename . 'resume_activite_' . uniqid() . '.pdf';
             //$pdf->Output($mon_url, F);
             $pdf->Output('../' . $mon_url, F);
             return json_encode($mon_url);
         } else {
             if ($arr['cas'] == 2) {
                 return json_encode("ok");
             }
         }
     } catch (Exception $e) {
         return 'Exception -> ';
         var_dump($e->getMessage());
     }
 }
function parse_pdf_content($content, $member_id)
{
    // parse text content from Smarty to pdf content
    global $db, $config, $t;
    $pdf_content = '';
    $margins = array(mm_to_pt(20), mm_to_pt(20), mm_to_pt(20), mm_to_pt(20));
    //left, top, right, bottom (in points) 56pt ~= 20mm
    $font_size = 14;
    //points
    $pdf = new FPDF('P', 'pt', 'A4');
    // portrait, A4
    $pdf->SetCompression(false);
    $pdf->SetMargins($margins[0], $margins[1], $margins[2]);
    //only left, top, right margins. bottom margin equals to 20mm by default.
    $pdf->SetTitle('Your Invoice');
    $pdf->SetSubject('*** Your Payment');
    $pdf->SetAuthor('aMember');
    $pdf->AddPage();
    $pdf->SetFont('Arial', '', $font_size);
    $current_x = $pdf->GetX();
    $current_y = $pdf->GetY();
    $width = mm_to_pt(210);
    $height = mm_to_pt(270);
    $width = $width - $margins[0] - $margins[2];
    // target width
    $height = $height - $margins[1] - $margins[3];
    // target height
    $image = $config['root_dir'] . "/logo.jpg";
    // logo path to include in pdf at top-right corner
    if (is_file($image)) {
        $size = getimagesize($image);
        $x = $width - $size[0] + $margins[0];
        $y = $current_y;
        $pdf->Image($image, $x, $y, $size[0], $size[1]);
        // use original size
        $current_y += $size[1];
    }
    $current_y += $font_size;
    //pt
    $contacts = explode("\n", $config['invoice_contacts']);
    // output contact information right-aligned
    $max_length = 0;
    foreach ($contacts as $row) {
        $row = trim($row);
        $length = $pdf->GetStringWidth($row);
        if ($length > $max_length) {
            $max_length = $length;
        }
    }
    $x = $width - $max_length + $margins[0];
    $y = $current_y;
    foreach ($contacts as $row) {
        $row = trim($row);
        $attr = get_font_styles($row);
        $pdf->SetFont('Arial', $attr, $font_size);
        $pdf->Text($x, $y, strip_tags($row));
        $y += $font_size;
    }
    $current_y = $y;
    $pdf->SetFont('Arial', '', $font_size);
    //return font settings
    // customer contacts
    $u = $db->get_user($member_id);
    if (!$t) {
        $t =& new_smarty();
    }
    $t->assign('u', $u);
    $cust_contacts = $t->fetch('mail_receipt_contact.pdf.txt');
    $cust_contacts = explode("\n", $cust_contacts);
    // output contact information left-aligned
    $num_rows = count($contacts);
    $x = $margins[0];
    $y = $current_y - $font_size * $num_rows;
    // $num_rows rows up from contact information and output customer data
    foreach ($cust_contacts as $row) {
        $row = trim($row);
        $attr = get_font_styles($row);
        $pdf->SetFont('Arial', $attr, $font_size);
        $pdf->Text($x, $y, strip_tags($row));
        $y += $font_size;
    }
    $current_y = $y;
    /*
    $y = $current_y - $font_size * 4; // 4 rows up from contact information and output customer data
    
    $string = $u['name_f'] . ' ' . $u['name_l'];
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    
    $string = $u['street'];
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    
    $string = $u['zip'] . ' ' . $u['city'];
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    
    	$state = db_getStateByCode($u['country'], $u['state']);
    	$country = db_getCountryByCode($u['country']);
    $string = $state .  ' '  . $country;
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    */
    $current_y = $y + $font_size * 2;
    //2 rows down
    $pdf->SetFont('Arial', '', $font_size);
    //return font settings
    // remove new lines
    $content = str_replace("\n", "", $content);
    $content = str_replace("\r", "", $content);
    $content = str_replace("&pound;", chr(163), $content);
    // split text by <br />
    $content = explode("<br />", $content);
    $y = $current_y;
    // count maximum columns widths
    $widths = array();
    foreach ($content as $text) {
        $text = trim($text);
        if (preg_match('/\\|/i', $text, $regs)) {
            $column = 0;
            $items = explode("|", $text);
            foreach ($items as $item) {
                $length = $pdf->GetStringWidth(trim(strip_tags($item))) + 10;
                if ($widths[$column] < $length) {
                    $widths[$column] = $length;
                }
                $column++;
            }
        }
    }
    $length = 0;
    for ($i = 1; $i < count($widths); $i++) {
        $length += $widths[$i];
    }
    // width of column 0 is *
    $widths[0] = $width - $length;
    foreach ($content as $hr_content) {
        $hr_content = trim($hr_content);
        // split text by <hr>
        $hr_content = explode("<hr>", $hr_content);
        $hr_count = count($hr_content) - 1;
        //<br /> add new line
        if ($hr_count < 1 && strip_tags($hr_content[0]) == '') {
            $y += $font_size;
        }
        foreach ($hr_content as $text) {
            $line_feeds = 1;
            // how much rows feed
            if (strip_tags($text) != '') {
                // if there is a text
                if (!preg_match('/\\|/i', $text, $regs)) {
                    // simple text
                    $y += $font_size * $line_feeds;
                    $attr = get_font_styles($text);
                    $text = trim(strip_tags($text));
                    $pdf->SetFont('Arial', $attr, $font_size);
                    $pdf->Text($x, $y, $text);
                    // simple textout. no line feeds allowed.
                    /*
                    $length = $pdf->GetStringWidth ($text);
                    while ($length > $width)
                        $line_feeds++;
                    */
                } else {
                    //table content (splitted by "|")
                    $border = 0;
                    $fill = 0;
                    $pdf->SetFillColor(192, 192, 192);
                    // Silver
                    if (preg_match('/<fill>(.*)<\\/fill>/i', $text, $regs)) {
                        $text = $regs[1];
                        $fill = 1;
                    }
                    $text = strip_tags($text);
                    $items = explode("|", $text);
                    $column = 0;
                    $x = $margins[0];
                    foreach ($items as $item) {
                        $attr = get_font_styles($item);
                        $item = trim(strip_tags($item));
                        $pdf->SetFont('Arial', $attr, $font_size);
                        if ($column > 0) {
                            $align = 'R';
                        } else {
                            $align = 'L';
                        }
                        $pdf->SetXY($x, $y);
                        $pdf->MultiCell($widths[$column], $font_size, $item, $border, $align, $fill);
                        // multi rows output
                        for ($i = 1; $i < $line_feeds; $i++) {
                            $_y = $y + $i * $font_size;
                            $pdf->SetXY($x, $_y);
                            $pdf->MultiCell($widths[$column], $font_size, '', $border, $align, $fill);
                            // empty rows
                        }
                        if ($column == 0) {
                            // count line feeds only for 0 column
                            $length = $pdf->GetStringWidth($item);
                            while ($length > $widths[$column]) {
                                $line_feeds++;
                                $length -= $widths[$column];
                            }
                        }
                        $x += $widths[$column];
                        $column++;
                    }
                    $y += $font_size * $line_feeds;
                    $pdf->SetXY($margins[0], $y);
                }
            }
            // (strip_tags($text) != '')
            if ($hr_count > 0) {
                // check count of <hr> (do not draw last <hr>)
                $y += 2;
                $pdf->Line($margins[0], $y, $margins[0] + $width, $y);
                $y += 2;
                $hr_count--;
            }
            $x = $margins[0];
        }
        //foreach hr_content
    }
    //foreach content
    $current_y = $y;
    $pdf_content = $pdf->Output('', 'S');
    //get pdf content
    return $pdf_content;
}
Exemple #27
0
$pdf->SetFont("Arial", "B", 32);
$pdf->SetXY(0, 30);
$pdf->Cell(0, 0, "SAMPLE DOC Oumar Exe ", 0, 0, C);
$pdf->SetFont("Arial", "", 12);
$pdf->SetTextColor(130, 0, 0);
$pdf->Text(10, 45, "Title 1 ");
$pdf->SetTextColor(0);
$pdf->SetTextColor(0, 130, 0);
$pdf->Text(20, 50, "Title 2 ");
$pdf->SetTextColor(0);
$pdf->SetTextColor(20, 20, 130);
$pdf->Text(30, 55, "Title 3 ");
$pdf->SetTextColor(0);
$pdf->SetXY(10, 60);
$pdf->Text(10, 60, "BONJOUR COUCOU GRAND Darktsar Oumar Exe TRAORE  ");
$cordX = $pdf->SetX($pdf->GetStringWidth("BONJOUR COUCOU GRAND Darktsar Oumar Exe TRAORE  "));
$cordX = $pdf->GetX() + 9;
$pdf->SetFont("Arial", "B", 12);
$pdf->Text($cordX, 60, "SAMPLE ");
$pdf->SetFont("Arial", "", 12);
$pdf->SetFont("Arial", "", 12);
$cordX = $pdf->SetX($pdf->GetStringWidth("SAMPLE ")) + 18 + $cordX;
$pdf->Text($cordX, 60, " Fin de texte darktsar");
$pdf->SetXY(10, 65);
$pdf->SetFont("Arial", "I", 12);
$pdf->Text(10, 65, "SAMPLE ");
$pdf->SetFont("Arial", "", 12);
$pdf->SetTextColor(0, 130, 0);
$pdf->Text(20, 70, "Titre super ");
$pdf->SetTextColor(0);
$pdf->SetXY(10, 75);
 public function pdfcreateAction()
 {
     require "lib/fpdf/fpdf.php";
     //Page footer
     function Footer()
     {
         //Position at 1.5 cm from bottom
         $this->SetY(-15);
         //Arial italic 8
         $this->SetFont('Arial', 'I', 8);
         //Page number
         $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
     }
     $pdf = new FPDF();
     $pdf->AliasNbPages();
     $todate = date("D M j Y");
     $time = date(" G:i:s T");
     $storePhone = Mage::getStoreConfig('general/store_information/phone');
     $store_email = Mage::getStoreConfig('trans_email/ident_support/email');
     $freeSubTotal = Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal');
     $session = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
     //print_r($session);die;
     $img_path = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/logo_print.gif';
     $telephone = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/telephone.png';
     $mail = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/mail.png';
     $indianrupee = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/rupee.png';
     $indian_rupee_symbol = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/total.png';
     $indian_rupee = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/savings.png';
     $sub_total = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/sub-total1.png';
     $shipping = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/shipping.png';
     $discount_image = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/discount.png';
     $store_address = Mage::getStoreConfig('general/store_information/address');
     $split_store_address = explode(',', $store_address);
     $pdf->AddPage();
     $linestyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 10, 'color' => array(255, 0, 0));
     $pdf->Image($img_path, 10, 20, 31, 20, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->SetX(100);
     $pdf->SetY(25);
     $pdf->SetFont('arial', 'B', 13);
     $pdf->Cell(180, 0, 'Quotation', 2, 2, 'C');
     $pdf->Line(90, 27, 110, 27, $linestyle);
     $pdf->SetX(100);
     $pdf->SetY(25);
     $pdf->SetFont('arial', 'B', 11);
     $pdf->Cell(0, 0, $split_store_address[0], 0, 0, 'R');
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 10, $split_store_address[1] . ',' . $split_store_address[2] . ',' . $split_store_address[3], 0, 0, 'R');
     $pdf->Cell(0, 20, $split_store_address[4] . ',' . $split_store_address[5], 0, 0, 'R');
     $pdf->Cell(0, 30, $split_store_address[6], 0, 0, 'R');
     $pdf->Line(10, 49, 200, 49, $linestyle);
     $pdf->SetX(20);
     $pdf->SetY(38);
     $pdf->SetFont('arial', 'B', 9);
     $pdf->Cell(0, 30, 'VAT/TIN :  ', 0, 0, 'L');
     $pdf->SetX(25);
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, ' 29471119182', 0, 0, 'L');
     $pdf->SetX(85);
     $pdf->SetFont('arial', 'B', 9);
     $pdf->Cell(0, 30, 'CST No:  ', 0, 0, 'L');
     $pdf->SetX(98);
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, ' 29471119182', 0, 0, 'L');
     $pdf->SetX(150);
     $pdf->SetFont('arial', 'B', 9);
     $pdf->Cell(0, 30, 'PAN No :  ', 0, 0, 'L');
     $pdf->SetX(164);
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, ' AALCA1282E', 0, 0, 'L');
     $pdf->Line(10, 57, 200, 57, $linestyle);
     $pdf->Line(10, 72, 200, 72, $linestyle);
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(20);
     $pdf->SetY(45);
     $pdf->Cell(0, 35, 'QUOTATION DATE : ', 0, 0, 'L');
     $pdf->SetX(125);
     $pdf->Cell(0, 35, 'FOR ANY QUERIES : ', 0, 0, 'L');
     $pdf->SetFont('arial', 'B', 9);
     $pdf->SetX(20);
     $pdf->SetY(50);
     $pdf->Cell(0, 35, $todate . ', ' . $time, 0, 0, 'L');
     $pdf->SetX(127);
     $pdf->Image($telephone, 125, 66, 3, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->Cell(0, 35, '+91-' . $storePhone, 0, 0, 'L');
     $pdf->Image($mail, 155, 66, 3, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->SetX(157);
     $pdf->Cell(0, 35, ' : ' . $store_email, 0, 0, 'L');
     $pdf->SetX(21);
     $pdf->SetY(60);
     $pdf->SetFont('arial', '', 9);
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         $firstname = $customer->getFirstname();
     } else {
         $firstname = 'Customer';
     }
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, 'Dear ' . $firstname . ',', 0, 0, 'L');
     //$pdf->SetX(20);
     $pdf->SetY(80);
     $pdf->Cell(0, 1, 'Thank you for your interest in buying from us. Please find the below details of your selected products', 0, 0, 'L');
     $pdf->SetFont('arial', 'B', 8);
     //$pdf->SetX(10);
     $pdf->SetY(90);
     //$pdf->SetX(10);
     $pdf->Cell(7, 10, 'S.No', 1, 0, 'C');
     $pdf->Cell(100, 10, 'Products', 1, 0, 'L');
     $pdf->Cell(20, 10, 'SKU', 1, 0, 'C');
     $pdf->Cell(20, 10, 'Price', 1, 0, 'C');
     $pdf->Image($indianrupee, 152, 94, 3, 2, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->Image($indianrupee, 197, 94, 3, 2, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->Cell(10, 10, 'Qty', 1, 0, 'C');
     $pdf->Cell(15, 10, 'Tax (%)', 1, 0, 'C');
     $pdf->Cell(20, 10, 'Sub Total', 1, 1, 'L');
     $j = 1;
     foreach ($session as $item) {
         if (!$item->getParentItem()) {
             $i = 10;
             $pdf->SetFont('arial', '', 9);
             $product_name = wordwrap($item->getName(), 15, TRUE);
             $font_size = 14;
             $decrement_step = 0.1;
             $line_width = 100;
             while ($pdf->GetStringWidth($item->getName()) > 98) {
                 $pdf->SetFontSize($font_size -= $decrement_step);
             }
             $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
             $item_total = ceil($item->getPriceInclTax()) * $item->getQty();
             $product_total = ceil($product->getPrice()) * $item->getQty();
             $pdf->SetX(10);
             $pdf->Cell(7, $i, $j, 1, 0, 'C');
             $pdf->Cell($line_width, 10, $item->getName(), 1, 0, 'L');
             //$pdf->Cell(50,$i,$product_name, 1,0,'C');
             $pdf->Cell(20, $i, $item->getSku(), 1, 0, 'C');
             $pdf->Cell(20, $i, number_format($item->getPriceInclTax(), 2), 1, 0, 'C');
             $pdf->Cell(10, $i, $item->getQty(), 1, 0, 'C');
             if ($product->getTypeId() == 'bundle') {
                 $pdf->Cell(15, $i, '-', 1, 0, 'C');
             } else {
                 $pdf->Cell(15, $i, number_format($item['tax_percent'], 1), 1, 0, 'C');
             }
             $pdf->Cell(20, $i, number_format($item->getPriceInclTax() * $item->getQty(), 2), 1, 1, 'C');
             $total = $total + $item->getPriceInclTax() * $item->getQty();
             $saving = $saving + $product_total;
             $j++;
         }
     }
     $totals1 = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
     $subtotal = $totals1["subtotal"]->getValue();
     $grandtotal = $totals1["grand_total"]->getValue();
     if (isset($totals1['discount']) && $totals1['discount']->getValue()) {
         $discount = number_format($totals1['discount']->getValue(), 2);
         //Discount value if applied
     }
     // exit;
     if ($total > $freeSubTotal) {
         $shipping_rate = '0.00';
     } else {
         if ($total < $freeSubTotal) {
             $shipping_rate = Mage::getStoreConfig('carriers/flatrate/price');
             $shipping_rate = number_format($shipping_rate, 2);
             $totals = $grandtotal + $shipping_rate;
         }
     }
     $pdf->SetFont('arial', '', 10);
     $saving_amount = '  ' . $saving - $total;
     $customer_care = Mage::getStoreConfig('general/store_information/phone');
     $pdf->Cell(192, 10, $pdf->Image($sub_total, 150, $pdf->GetY() + 4, 27, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . number_format($total, 2), 1, 2, 'R');
     //$pdf->Cell(192,10,'Sub Total:'.number_format($total,2), 1,2,'R');
     $pdf->Cell(192, 10, $pdf->Image($shipping, 142, $pdf->GetY() + 4, 27, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . $shipping_rate, 1, 2, 'R');
     //$pdf->Cell(192,10,'Shipping & Handling:	'.$shipping_rate, 1,2,'R');
     if ($discount != NULL) {
         $pdf->Cell(192, 10, $pdf->Image($discount_image, 142, $pdf->GetY() + 4, 26, 2.5, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . $discount, 1, 2, 'R');
         //$pdf->Cell(192,10,'Discount Amount:	'.$discount, 1,2,'R');
     }
     $pdf->SetFont('arial', 'B', 12);
     $pdf->Cell(96, 10, $pdf->Image($indian_rupee, 20, $pdf->GetY() + 3, 27, 4, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . number_format($saving_amount, 2), 1, 0, 'C');
     if ($totals != NULL) {
         $pdf->Cell(96, 10, $pdf->Image($indian_rupee_symbol, 115, $pdf->GetY() + 3, 27, 4, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '  ' . number_format($totals, 2), 1, 0, 'C');
     } else {
         $pdf->Cell(96, 10, $pdf->Image($indian_rupee_symbol, 115, $pdf->GetY() + 3, 27, 4, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '  ' . number_format($grandtotal, 2), 1, 0, 'C');
     }
     $pdf->SetX(5);
     $statement1 = 'We would be happy to fulfill your order at the earliest.';
     $statement1_1 = ' Zoffio helps you save upto 60% on all your office needs and guarantees ';
     $statement1_2 = 'you the best quality original products';
     $statement2 = 'Complete your order today so as not to lose out of the savings!';
     $statement3 = 'You can also contact our customer care support team for more information.';
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 45, $statement1, 0, 0, 'L');
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(80);
     $pdf->Cell(0, 45, $statement1_1, 0, 0, 'L');
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(5);
     $pdf->Cell(0, 55, $statement1_2, 0, 0, 'L');
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(5);
     $pdf->Cell(0, 70, $statement2, 0, 0, 'L');
     $pdf->SetX(5);
     $pdf->Cell(0, 80, $statement3 . '- +91- ' . $customer_care, 0, 0, 'L');
     $pdf->SetX(5);
     $pdf->Cell(0, 95, 'Best Wishes', 0, 0, 'L');
     $pdf->SetX(5);
     $pdf->Cell(0, 105, 'Zoffio Team', 0, 0, 'L');
     $pdf->SetTextColor(0, 8, 8);
     $pdf->SetFont('arial', '', 7);
     $pdf->SetY(-15);
     $pdf->Cell(0, -10, '(This quotation is generated from the website Zoffio.com in real time. As prices are dynamic, so please recheck the price before confirmation)', 0, 0, 'C');
     $pdf->Output('Zoffio-quotation.pdf', 'D');
 }
$imgSpacingBorder = 1.5;
$pdf->Image('resources/certificates/border_L.png', $xMarginLeft + $imgSpacingBorder, $yMarginTop + $imgSpacingBorder, $imgScaleBorder);
$pdf->Image('resources/certificates/watermark_light.png', ($wTextArea - $imgScaleWatermark) / 2 + $xLeftTextMargin, $yMarginTop + 7, $imgScaleWatermark);
$pdf->Image('resources/certificates/border_R.png', $xMarginRight - $imgSpacingBorder - $imgScaleBorder, $yMarginBottom - $imgSpacingBorder - $imgScaleBorder, $imgScaleBorder);
//** Title **
$yLine = $yMarginTop + 16;
$pdf->SetFont('Porcelain', '', 42);
$pdf->SetY($yLine);
$pdf->Cell(0, 10, $textTitle, 0, 1, 'C');
//** Body Lines **
$pdf->SetFont('DemiTasse');
$pdf->SetFontSize(14);
$pdf->SetDrawColor(0, 0, 0);
//** Line 1: Gifts **
$yLine = $yLine + 22;
$wStatic = $pdf->GetStringWidth($textGiftStatic);
// $wDynamic = $pdf->GetStringWidth($textGiftDynamic);
$wAvailForDynaimc = $wTextArea - $wStatic - 2 * $wSpace;
//Case 1: Fits on one line
$wDynamic = $pdf->GetStringWidth($textGiftDynamic);
if ($wDynamic <= $wAvailForDynaimc) {
    // $pdf->SetXY(10,10);
    // $pdf->Cell(20,0, "DEBUG: case 1");
    $wSideSpacing = ($wTextArea - $wStatic - $wDynamic - 2 * $wSpace) / 2;
    $xStatic = $xLeftTextMargin + $wSideSpacing;
    $pdf->SetXY($xStatic, $yLine);
    $pdf->Cell($wStatic, 10, $textGiftStatic, 0, 0, 'L');
    $xDynamic = $xStatic + $wStatic + $wSpace;
    $pdf->SetXY($xDynamic, $yLine);
    $pdf->Cell($wDynamic, 10, $textGiftDynamic, 0, 0, 'L');
    $x1 = $xStatic + $wStatic;
 function validateSizeColumns($header)
 {
     $i = 0;
     $plus = 0;
     $wmax = $this->wMaxCol;
     foreach ($this->widthCol as $colS) {
         $size = round(parent::GetStringWidth($header[$i]["name"])) + 3;
         //echo parent::GetStringWidth($header[$i]["name"]);
         //echo $header[$i]["name"];
         $this->widthCol[$i] = max($colS, $size);
         //  echo "head: {$size}, col: {$colS}";
         if ($plus > 0) {
             $wmax = $wmax + $plus;
         }
         if ($this->widthCol[$i] > $wmax) {
             $this->widthCol[$i] = $wmax;
         }
         $plus = $wmax - $this->widthCol[$i];
         //echo "plus: {$plus}, col: {$this->widthCol[$i]}, maxvar: {$wmax}, maxfijo:{$this->wMaxCol}";
         $wmax = $this->wMaxCol;
         $i++;
     }
 }