1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Ghostscript package |
4
|
|
|
* |
5
|
|
|
* @author Simon Schrape <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace GravityMedia\Ghostscript\Device; |
9
|
|
|
|
10
|
|
|
use GravityMedia\Ghostscript\Ghostscript; |
11
|
|
|
use GravityMedia\Ghostscript\Process\Arguments; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* The PDF info device class. |
15
|
|
|
* |
16
|
|
|
* This class supports the pdf_info.ps script that is contained in Ghostscript toolbin. |
17
|
|
|
* |
18
|
|
|
* @link http://svn.ghostscript.com/ghostscript/trunk/gs/toolbin/ |
19
|
|
|
* |
20
|
|
|
* @package GravityMedia\Ghostscript\Devices |
21
|
|
|
*/ |
22
|
|
|
class PdfInfo extends NoDisplay |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* The PDF info path. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $pdfInfoPath; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Create PDF info device object. |
33
|
|
|
* |
34
|
|
|
* @param Ghostscript $ghostscript |
35
|
|
|
* @param Arguments $arguments |
36
|
|
|
* @param string $pdfInfoPath Path to toolbin/pdf_info.ps |
37
|
|
|
*/ |
38
|
|
|
public function __construct(Ghostscript $ghostscript, Arguments $arguments, $pdfInfoPath) |
39
|
|
|
{ |
40
|
|
|
parent::__construct($ghostscript, $arguments); |
41
|
|
|
|
42
|
|
|
$this->pdfInfoPath = $pdfInfoPath; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Create process object. |
47
|
|
|
* |
48
|
|
|
* @param string $input Path to PDF file to be examined |
49
|
|
|
* |
50
|
|
|
* @throws \RuntimeException |
51
|
|
|
* |
52
|
|
|
* @return \Symfony\Component\Process\Process |
53
|
|
|
*/ |
54
|
|
|
public function createProcess($input = null) |
55
|
|
|
{ |
56
|
|
|
if (!is_string($input) || !file_exists($input)) { |
57
|
|
|
throw new \RuntimeException('Input file does not exist'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$this->setArgument(sprintf('-sFile=%s', $input)); |
61
|
|
|
|
62
|
|
|
return parent::createProcess($this->pdfInfoPath); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|