}
}
+ if($this->mimetype == 'application/pdf'){
+ $this->no_of_pages = $this->getPdfPages($file);
+ }
+
$this->filesize = filesize($file);
$this->created = date('Y-m-d H:i:s');
{
$opts = HTML_FlexyFramework::get()->Pman;
$fn = preg_replace('/[^a-z0-9\.]+/i', '_', $this->filename);
+ print_r($opts);exit;
return implode( '/', array(
$opts['storedir'], '_images_', date('Y/m', strtotime($this->created)), $this->id . '-'. $fn
));
$this->filesize = filesize($f);
+ if($this->mimetype == 'application/pdf'){
+ $this->no_of_pages = $this->getPdfPages($f);
+ }
+
$this->update($o);
return true;
return $base64;
}
- function getNumberOfPages()
+ function getPdfPages($file)
{
- $ret = 0;
+ require_once 'System.php';
- switch ($this->mimetype) {
- case 'application/pdf' :
- break;
- default :
- break;
+ $page = 0;
+
+ $pdfinfo = System::which('pdfinfo');
+
+ if (!file_exists($file) || empty($pdfinfo)) {
+ return $page;
}
- return $ret;
+ $cmd = "{$pdfinfo} {$file}";
+
+ $ret = `$cmd`;
+
+ $info = explode("\n", $ret);
+
+ foreach ($info as $i){
+
+ if(!preg_match('/^Pages:[\s]*([0-9]+)/', $i, $matches)){
+ continue;
+ }
+
+ $page = (empty($matches[1])) ? 0 : $matches[1];
+ }
+
+ return $page;
}
}