mikehaertl\pdftk\Pdf::setPassword PHP Method

setPassword() public method

public setPassword ( string $password ) : Pdf
$password string the owner password to set on the output PDF
return Pdf the pdf instance for method chaining
    public function setPassword($password)
    {
        $this->getCommand()->addOption('owner_pw', $password, true);
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 public function testCanSetPasswords()
 {
     $document = $this->getDocument1();
     $file = $this->getOutFile();
     $pdf = new Pdf($document);
     $this->assertInstanceOf('mikehaertl\\pdftk\\Pdf', $pdf->setPassword('"\'**'));
     $this->assertInstanceOf('mikehaertl\\pdftk\\Pdf', $pdf->setUserPassword('**"\''));
     $this->assertTrue($pdf->saveAs($file));
     $this->assertFileExists($file);
     $tmpFile = (string) $pdf->getTmpFile();
     $this->assertEquals("pdftk A='{$document}' output '{$tmpFile}' owner_pw '\"'\\''**' user_pw '**\"'\\'''", (string) $pdf->getCommand());
 }