phpdftk API Documentation

PageTransformer
in package

FinalYes

Transform page geometry — rotate, scale, and set page boxes.

Uses incremental updates so the original PDF content is preserved intact and only modified page dictionaries are appended.

Usage: PageTransformer::open('input.pdf') ->rotate(90) ->setCropBox(0, 0, 300, 400, PageSelector::pages(1)) ->save('output.pdf');

Table of Contents

Methods

getPageCount()  : int
getReader()  : PdfReader
getVersionWarnings()  : array<int, string>
open()  : self
openString()  : self
rotate()  : self
Rotate pages by the given angle.
save()  : void
scale()  : self
Scale pages by a uniform factor.
scaleTo()  : self
Scale pages to fit the given dimensions.
setBleedBox()  : self
Set the BleedBox on selected pages.
setCropBox()  : self
Set the CropBox on selected pages.
setMediaBox()  : self
Set the MediaBox on selected pages.
setTrimBox()  : self
Set the TrimBox on selected pages.
toBytes()  : string

Methods

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

rotate()

Rotate pages by the given angle.

public rotate(int $degrees[, PageSelector|null $pages = null ]) : self
Parameters
$degrees : int

Must be 0, 90, 180, or 270

$pages : PageSelector|null = null
Return values
self

scale()

Scale pages by a uniform factor.

public scale(float $factor[, PageSelector|null $pages = null ]) : self

Multiplies all page box dimensions (MediaBox, CropBox, etc.) by the factor.

Parameters
$factor : float
$pages : PageSelector|null = null
Return values
self

scaleTo()

Scale pages to fit the given dimensions.

public scaleTo(float $width, float $height[, PageSelector|null $pages = null ]) : self

Computes the uniform scale factor from the MediaBox and applies it.

Parameters
$width : float
$height : float
$pages : PageSelector|null = null
Return values
self

setBleedBox()

Set the BleedBox on selected pages.

public setBleedBox(float $x, float $y, float $w, float $h[, PageSelector|null $pages = null ]) : self
Parameters
$x : float
$y : float
$w : float
$h : float
$pages : PageSelector|null = null
Return values
self

setCropBox()

Set the CropBox on selected pages.

public setCropBox(float $x, float $y, float $w, float $h[, PageSelector|null $pages = null ]) : self
Parameters
$x : float
$y : float
$w : float
$h : float
$pages : PageSelector|null = null
Return values
self

setMediaBox()

Set the MediaBox on selected pages.

public setMediaBox(float $x, float $y, float $w, float $h[, PageSelector|null $pages = null ]) : self
Parameters
$x : float
$y : float
$w : float
$h : float
$pages : PageSelector|null = null
Return values
self

setTrimBox()

Set the TrimBox on selected pages.

public setTrimBox(float $x, float $y, float $w, float $h[, PageSelector|null $pages = null ]) : self
Parameters
$x : float
$y : float
$w : float
$h : float
$pages : PageSelector|null = null
Return values
self

        
On this page

Search results