phpdftk API Documentation

PdfStamper
in package

FinalYes

Add text overlays, watermarks, page numbers, headers and footers to PDFs.

Usage: PdfStamper::open('report.pdf') ->watermark('DRAFT') ->addPageNumbers(StampPosition::BottomCenter) ->save('stamped.pdf');

Table of Contents

Methods

addPageNumbers()  : self
footer()  : self
getPageCount()  : int
getReader()  : PdfReader
getVersionWarnings()  : array<int, string>
header()  : self
open()  : self
openString()  : self
save()  : void
stampImage()  : self
Overlay a JPEG or PNG image at a given position on selected pages.
stampPdf()  : self
Overlay a page from another PDF at a given position on selected pages.
stampText()  : self
toBytes()  : string
watermark()  : self

Methods

getPageCount()

public getPageCount() : int
Return values
int

getVersionWarnings()

public getVersionWarnings() : array<int, string>
Return values
array<int, string>

open()

public static open(string $path[, string $password = '' ]) : self
Parameters
$path : string
$password : string = ''
Return values
self

openString()

public static openString(string $pdfBytes[, string $password = '' ]) : self
Parameters
$pdfBytes : string
$password : string = ''
Return values
self

save()

public save(string $path) : void
Parameters
$path : string

stampImage()

Overlay a JPEG or PNG image at a given position on selected pages.

public stampImage(string $imagePath, StampPosition $position[, PageSelector|null $pages = null ][, ImageStampStyle|null $style = null ]) : self

Dimensions default to the image's native pixel size (at 72 DPI). Set width or height in the style to scale; setting one preserves the aspect ratio. Set both to stretch.

Parameters
$imagePath : string
$position : StampPosition
$pages : PageSelector|null = null
$style : ImageStampStyle|null = null
Return values
self

stampPdf()

Overlay a page from another PDF at a given position on selected pages.

public stampPdf(string $pdfPath[, int $pageIndex = 0 ][, StampPosition|null $position = null ][, PageSelector|null $pages = null ][, ImageStampStyle|null $style = null ]) : self

The source page is imported as a Form XObject. Dimensions default to the source page's MediaBox size. Use width/height in the style to scale.

Parameters
$pdfPath : string

Path to the source PDF file

$pageIndex : int = 0

0-based page index in the source PDF

$position : StampPosition|null = null
$pages : PageSelector|null = null
$style : ImageStampStyle|null = null
Return values
self

toBytes()

public toBytes() : string
Return values
string

        
On this page

Search results