public function setDefaultValues() { $defaults = parent::setDefaultValues(); $defaults['selected_profile'] = 'Default'; $defaults['pdfinfo_path'] = CRM_Donrec_Logic_Settings::get('donrec_pdfinfo_path'); $defaults['packet_size'] = CRM_Donrec_Logic_Settings::get('donrec_packet_size'); return $defaults; }
/** * get page count for a pdf file * * @return int page count (-1 if there is an error) */ private function getPDFPageCount($document) { $pdfinfo_path = CRM_Donrec_Logic_Settings::get('donrec_pdfinfo_path'); $cmd = escapeshellarg($pdfinfo_path); $document = escapeshellarg($document); $cmd = escapeshellcmd("{$cmd} {$document}") . " 2>&1"; exec($cmd, $output); $count = 0; foreach ($output as $line) { // Extract the number if (preg_match("/Pages:\\s*(\\d+)/i", $line, $matches) === 1) { return intval($matches[1]); } } return -1; }