public addFile ( string | |
||
$name | string | |
the PDF filename or Pdf instance to add for processing |
$handle | string | null | one or more uppercase letters A..Z to reference this file later. If no handle is provided, an internal handle is autocreated, consuming the range Z..A |
$password | string | null | the owner (or user) password if any |
return | the pdf instance for method chaining |
public function addFile($name, $handle = null, $password = null)
{
if ($handle === null || is_numeric($handle)) {
$handle = $this->nextHandle();
}
if ($name instanceof Pdf) {
// Keep a reference to the object to prevent unlinking
$this->_pdf = $name;
if (!$name->getCommand()->getExecuted()) {
// @todo: Catch errors!
$name->execute();
}
$name = (string) $name->getTmpFile();
}
$this->getCommand()->addFile($name, $handle, $password);
return $this;
}
public function testCanPerformEmptyOperation() { $document1 = $this->getDocument1(); $file = $this->getOutFile(); $pdf = new Pdf(); $this->assertInstanceOf('mikehaertl\\pdftk\\Pdf', $pdf->addFile($document1, null, 'complex\'"password')); $this->assertTrue($pdf->saveAs($file)); $this->assertFileExists($file); $tmpFile = (string) $pdf->getTmpFile(); $this->assertEquals("pdftk A='{$document1}' input_pw A='complex'\\''\"password' output '{$tmpFile}'", (string) $pdf->getCommand()); }