mikehaertl\pdftk\Pdf::background PHP Method

background() public method

The PDF file must have a transparent background for the watermark to be visible.
public background ( string $file ) : Pdf
$file string name of the background PDF file. Only the first page is used.
return Pdf the pdf instance for method chaining
    public function background($file)
    {
        $this->constrainSingleFile();
        $this->getCommand()->setOperation('background')->setOperationArgument($file, true);
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testCanSetBackground()
 {
     $document1 = $this->getDocument1();
     $document2 = $this->getDocument2();
     $file = $this->getOutFile();
     $pdf = new Pdf($document1);
     $this->assertInstanceOf('mikehaertl\\pdftk\\Pdf', $pdf->background($document2));
     $this->assertTrue($pdf->saveAs($file));
     $this->assertFileExists($file);
     $tmpFile = (string) $pdf->getTmpFile();
     $this->assertEquals("pdftk A='{$document1}' background '{$document2}' output '{$tmpFile}'", (string) $pdf->getCommand());
 }