Пример #1
0
 public function setUp()
 {
     if (!class_exists('Poppler\\Processor\\PdfFile')) {
         $this->markTestSkipped('Poppler\\Processor\\PdfFile not available.');
     }
     try {
         $this->reader = new PdfInfoReader(new PdfFile(\Poppler\Driver\Pdfinfo::create(), \Poppler\Driver\Pdftotext::create(), \Poppler\Driver\Pdftohtml::create()));
     } catch (\Exception $e) {
         $this->markTestSkipped('PdfInfoReader not available.');
     }
 }
 public function testGetInfo()
 {
     $pdfFile = new PdfFile(Pdfinfo::create($this->createLoggerMock()), $this->createPdftotextMock(), $this->createPdftohtmlMock());
     $info = $pdfFile->getInfo(__DIR__ . '/../files/pdf-sample.pdf');
     $this->assertNotEmpty($info);
     $this->assertInternalType('array', $info);
     $this->assertSame('This is a test PDF file', $info['Title']);
     $this->assertSame('1', $info['Pages']);
     $this->assertSame('1.3', $info['PDF version']);
     $this->assertSame('Thu Jun 29 10:21:08 2000', $info['CreationDate']);
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * @expectedException \Poppler\Exception\ExecutableNotFoundException
  */
 public function testCreateFailureThrowsAnException()
 {
     Pdfinfo::create($this->createLoggerMock(), array('pdfinfo.binaries' => '/path/to/nowhere'));
 }