Esempio n. 1
0
 function Image($file, $x, $y, $w = 0, $h = 0, $ext = '', $link = '')
 {
     global $config;
     $image_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png', 6 => 'bmp');
     list($width, $height, $ext, $attr) = getimagesize($file);
     $ext = $image_types[$ext];
     // find image loading function
     switch ($ext) {
         case 'jpg':
             $func = 'jpeg';
             break;
         case 'bmp':
             $func = 'wbmp';
             break;
         default:
             $func = $ext;
     }
     $func = 'imagecreatefrom' . $func;
     // check if loading functions exists (especially for gif support)
     $im = function_exists($func) ? $func($file) : imagecreatetruecolor(1, 1);
     // scaling requested?
     if ($this->Scale) {
         $this->max_width = round($this->Scale * $config['pdf_image_max_width']);
         $this->max_height = round($this->Scale * $config['pdf_image_max_height']);
         $scale = min($this->max_width / $width, $this->max_height / $height);
         $thumb_x = round($width * $scale);
         $thumb_y = round($height * $scale);
     }
     // scaling requied?
     if ($this->Scale && ($thumb_x != $width || $thumb_y != $height)) {
         // create white truecolor image (in case original is transparent)
         $target = imagecreatetruecolor($thumb_x, $thumb_y);
         $white = imagecolorallocate($target, 255, 255, 255);
         imagefilledrectangle($target, 0, 0, $thumb_x, $thumb_y, $white);
         imagecopyresampled($target, $im, 0, 0, 0, 0, $thumb_x, $thumb_y, $width, $height);
         $this->GDImage($file, $x, $y, $w, $h, $target, $link, 'jpeg');
         // change to png if you receive acrobat errors
         imagedestroy($target);
     } elseif ($ext == 'gif') {
         // pdf doesn't support interlaced images
         if (imageinterlace($im)) {
             // claim non-interlaced image
             imageinterlace($im, false);
         }
         $this->GDImage($file, $x, $y, $w, $h, $im, $link);
     } else {
         parent::Image($file, $x, $y, $w, $h, $ext, $link);
     }
     imagedestroy($im);
 }
Esempio n. 2
0
}
$pageCount = 0;
// Instanciation of inherited class
foreach ($csv->data as $csvKey => $csvRow) {
    //Iterate pages.
    foreach ($server->outData['data'] as $pgKey => $pgData) {
        $pageCount++;
        $orientation = "L";
        if ($pgData['width'] < $pgData['height']) {
            $orientation = "P";
        }
        $pdf->AddPage($orientation, array($pgData['width'], $pgData['height']));
        $pageSize = array("width" => $pgData['width'], "height" => $pgData['height']);
        // Set the background.
        if (strlen($pgData['data_path'] . $pgData['file_name']) > 0) {
            $pdf->Image('../' . $server->outData['data'][$pgKey]['data_path'] . $server->outData['data'][$pgKey]['file_name'], 0, 0, $pgData['width'], 0);
            //210,0 means stretch horizontally, fill veritcally.   //-150 //210,297            //0,0,-300
        }
        $pdf->SetFontSize(19);
        $pageVariables = $pgData['variables'];
        //json_decode($pgData['variables'], 1);
        //Check that out variables json was correct json.
        if (is_array($pageVariables)) {
            //Iterate variables in the page.
            foreach ($pageVariables as $key => $data) {
                //Determine the font color.
                preg_match('/^rgb\\((\\d+), (\\d+), (\\d+)\\)$/', $data['font_color'], $fontColor);
                $pdf->SetTextColor($fontColor[1], $fontColor[2], $fontColor[3]);
                switch ($data['font_family']) {
                    case "Arial":
                        $fontSize = $data['font_size'] * 0.8100000000000001;