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
addPageNumbers()
public
addPageNumbers([StampPosition $position = StampPosition::BottomCenter ][, string $format = 'Page {n} of {total}' ][, StampStyle|null $style = null ][, PageSelector|null $pages = null ]) : self
Parameters
- $position : StampPosition = StampPosition::BottomCenter
- $format : string = 'Page {n} of {total}'
- $style : StampStyle|null = null
- $pages : PageSelector|null = null
Return values
selffooter()
public
footer(string $text[, StampStyle|null $style = null ][, PageSelector|null $pages = null ]) : self
Parameters
- $text : string
- $style : StampStyle|null = null
- $pages : PageSelector|null = null
Return values
selfgetPageCount()
public
getPageCount() : int
Return values
intgetReader()
public
getReader() : PdfReader
Return values
PdfReadergetVersionWarnings()
public
getVersionWarnings() : array<int, string>
Return values
array<int, string>header()
public
header(string $text[, StampStyle|null $style = null ][, PageSelector|null $pages = null ]) : self
Parameters
- $text : string
- $style : StampStyle|null = null
- $pages : PageSelector|null = null
Return values
selfopen()
public
static open(string $path[, string $password = '' ]) : self
Parameters
- $path : string
- $password : string = ''
Return values
selfopenString()
public
static openString(string $pdfBytes[, string $password = '' ]) : self
Parameters
- $pdfBytes : string
- $password : string = ''
Return values
selfsave()
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
selfstampPdf()
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
selfstampText()
public
stampText(string $text, StampPosition $position[, PageSelector|null $pages = null ][, StampStyle|null $style = null ]) : self
Parameters
- $text : string
- $position : StampPosition
- $pages : PageSelector|null = null
- $style : StampStyle|null = null
Return values
selftoBytes()
public
toBytes() : string
Return values
stringwatermark()
public
watermark(string $text[, PageSelector|null $pages = null ][, WatermarkStyle|null $style = null ]) : self
Parameters
- $text : string
- $pages : PageSelector|null = null
- $style : WatermarkStyle|null = null