/** * Write to file or return content * * @param string $inputfile * * @return array */ public function getInfo($inputfile) { if (!file_exists($inputfile)) { throw new FileNotFoundException("File {$inputfile} not found."); } $args = array($inputfile); $output = $this->pdfinfo->command($args); $info = array(); foreach (explode(PHP_EOL, $output) as $line) { if (strpos($line, ': ') === false) { continue; } $parts = explode(': ', $line); $key = trim($parts[0]); $value = trim($parts[1]); $info[$key] = $value; } return $info; }