Exemplo n.º 1
0
 public function ConvertAllPdf2Image($originalPdfPath, $targetFolder, $format, $width = null, $height = null)
 {
     $originalPdfFile = WeFlex_Util::GetFileName($originalPdfPath);
     $tempImagePath = $targetFolder . '/' . substr($originalPdfFile, 0, strrpos($originalPdfFile, '.')) . "." . $format;
     $tempImagePathPre = $targetFolder . '/' . substr($originalPdfFile, 0, strrpos($originalPdfFile, '.'));
     $originalPdfTemp = $originalPdfPath;
     $rtn = array();
     if ($width || $height) {
         $resize = " -resize ";
     }
     if ($width && !$height) {
         $resize .= $width . "x";
     } elseif (!$width && $height) {
         $resize .= "x" . $height;
     } elseif ($width && $height) {
         $resize .= $width . "x" . $height;
     }
     $cmd = 'convert -colorspace rgb  ' . $resize . '  ' . $originalPdfTemp . ' ' . $tempImagePath;
     exec($cmd);
     $i = 0;
     while (file_exists($tempImagePathPre . '-' . $i . '.' . $format)) {
         $rtn[] = $tempImagePathPre . '-' . $i . '.' . $format;
         $i++;
     }
     return $rtn;
 }
Exemplo n.º 2
0
 /** 
  * A Wrapper of original addFile Function 
  * 
  * Created By Hasin Hayder at 29th Jan, 1:29 AM 
  * 
  * @param array An Array of files with relative/absolute path to be added in Zip File 
  * 
  * @access public 
  */
 function addFiles($files, $names = null)
 {
     foreach ($files as $key => $file) {
         if ($names) {
             if (is_file($file)) {
                 $data = implode("", file($file));
                 $this->addFile($data, $names[$key]);
             }
         } else {
             if (is_file($file)) {
                 $data = implode("", file($file));
                 $file = '/' . WeFlex_Util::GetFileName($file);
                 $this->addFile($data, $file);
             }
         }
     }
 }