Page

Page API reference

Namespace: Com\Tecnick\Pdf\Page

class Page extends Region

Extends: Region

Source: src/Page.php:46

Methods

__construct()

Initialize page data.

public __construct(
    string|Unit $unit,
    Pdf $color,
    Encrypt $encrypt,
    bool $notransparency = false,
    bool $compress = true,
    bool $sigapp = false
)

Parameters:

  • $unit (string|Unit): Unit of measure (‘pt’, ‘mm’, ‘cm’, ‘in’) or a Unit enum case.
  • $color (Pdf): Color object.
  • $encrypt (Encrypt): Encrypt object.
  • $notransparency (bool): True when the conformance mode forbids transparency (PDF/A-1, PDF/X-1a, PDF/X-3): the page transparency group is suppressed.
  • $compress (bool): Set to false to disable stream compression.
  • $sigapp (bool): True if the signature approval is enabled (for incremental updates).

Throws:

Source: src/Page.php:62

addAnnotRef()

Add Annotation references.

Object IDs lower than 1 are ignored.

public addAnnotRef(int $oid, int $pid = -1): void

Parameters:

  • $oid (int): Annotation object IDs.
  • $pid (int): Page index. Omit or set it to -1 for the current page.

Throws:

Source: src/Page.php:379

addContent()

Add page content.

public addContent(string $content, int $pid = -1): void

Parameters:

  • $content (string): Page content.
  • $pid (int): Page index. Omit or set it to -1 for the current page.

Throws:

Source: src/Page.php:404

addContentMark()

Add page content mark.

public addContentMark(int $pid = -1): void

Parameters:

  • $pid (int): Page index. Omit or set it to -1 for the current page.

Throws:

Source: src/Page.php:446

delete()

Remove the specified page.

public delete(int $pid = -1): PageData

Parameters:

  • $pid (int): Page index. Omit or set it to -1 for the current page.

Returns: PageData: Removed page.

Throws:

Source: src/Page.php:221

enableSignatureApproval()

Enable Signature Approval.

public enableSignatureApproval(bool $sigapp): static

Parameters:

  • $sigapp (bool): True if the signature approval is enabled (for incremental updates).

Returns: static

Source: src/Page.php:93

getKUnit()

Get the unit ratio.

public getKUnit(): float

Returns: float: Unit Ratio.

Source: src/Page.php:83

getPages()

Returns the array (stack) containing all pages data.

public getPages(): array<int,PageData>

Returns: array<int,PageData>: Pages.

Source: src/Page.php:365

getPdfPages()

Returns the PDF command to output all page sections.

public getPdfPages(int &$pon): string

Parameters:

  • $pon (int): Current PDF object number.

Returns: string: PDF command.

Throws:

Source: src/Page.php:496

getResourceDictObjID()

Returns the reserved Object ID for the Resource dictionary.

public getResourceDictObjID(): int

Returns: int: Resource dictionary Object ID.

Source: src/Page.php:616

getRootObjID()

Returns the root object ID.

public getRootObjID(): int

Returns: int: Root Object ID.

Source: src/Page.php:626

keepPageBox()

Restore a page box previously excluded with omitPageBox().

public keepPageBox(string|PageBoxType $type): static

Parameters:

  • $type (string|PageBoxType): Box type: CropBox, BleedBox, TrimBox or ArtBox.

Returns: static

Throws:

Source: src/Page.php:148

move()

Move a page to a previous position.

public move(int $from, int $new): void

Parameters:

  • $from (int): Index of the page to move.
  • $new (int): Destination index.

Throws:

Source: src/Page.php:293

omitPageBox()

Exclude a page box from the page dictionary of every page.

ISO 15930 (PDF/X) requires a page to carry a trim box or an art box, but not both, so a conforming producer has to drop one of them. The box data is still computed and used for layout; only the page dictionary entry is omitted.

The MediaBox is required by ISO 32000-1 and cannot be omitted.

public omitPageBox(string|PageBoxType $type): static

Parameters:

  • $type (string|PageBoxType): Box type: CropBox, BleedBox, TrimBox or ArtBox.

Returns: static

Throws:

Source: src/Page.php:130

pop()

Remove and return last page.

public pop(): PageData

Returns: PageData: Removed page.

Throws:

Source: src/Page.php:280

popContent()

Remove and return last page content.

public popContent(int $pid = -1): string

Parameters:

  • $pid (int): Page index. Omit or set it to -1 for the current page.

Returns: string

Throws:

Source: src/Page.php:420

popContentToLastMark()

Remove the last marked page content.

public popContentToLastMark(int $pid = -1): void

Parameters:

  • $pid (int): Page index. Omit or set it to -1 for the current page.

Throws:

Source: src/Page.php:466

setPageTransparency()

Record whether the given page uses transparency.

In ‘auto’ mode a page flagged false omits the per-page transparency /Group; unflagged pages emit it.

public setPageTransparency(bool $hasTransparency = true, int $pid = -1): static

Parameters:

  • $hasTransparency (bool): True if the page uses actual transparency.
  • $pid (int): Page index. Omit or set it to -1 for the current page.

Returns: static

Throws:

Source: src/Page.php:110

setPageTransparencyGroupMode()

Set the policy for emitting the per-page transparency /Group on standard (non PDF/A) pages.

  • ‘auto’ : (default) emit the group on every standard page except those flagged as opaque via setPageTransparency(false, $pid).
  • ‘always’ : emit the group on every standard page.
  • ’never’ : never emit the group.

The mode is matched case-insensitively and unknown values are treated as ‘auto’.

public setPageTransparencyGroupMode(string|TransparencyGroupMode $mode): static

Parameters:

  • $mode (string|TransparencyGroupMode): One of ‘auto’, ‘always’, ’never’, or a TransparencyGroupMode case.

Returns: static

Source: src/Page.php:187

Inherited members

From Box

From Format

From Mode

From Region

  • MAX_BANDS: Maximum number of horizontal slices buildWritableRegions() may cut the content area into.
  • add(): Add a new page.
  • addNoWriteRegion(): Append a single no-write area to the page and rebuild the writable regions.
  • buildWritableRegions(): Build the ordered list of writable rectangular regions that avoid the given no-write areas.
  • checkRegionBreak(): Move to the next page region if required.
  • enableAutoPageBreak(): Enable or disable automatic page break.
  • getNextPage(): Returns the next page data.
  • getNextRegion(): Returns the page data with the next selected region.
  • getNoWriteRegions(): Return the no-write areas currently stored for the page.
  • getPage(): Returns the specified page data.
  • getRegion(): Returns the current region data.
  • getX(): Return the absolute horizontal cursor position for the current region.
  • getY(): Return the absolute vertical cursor position for the current region.
  • isAutoPageBreakEnabled(): Return the auto-page-break status.
  • isXOutRegion(): Check if the specified horizontal position is outside the region.
  • isYOutRegion(): Check if the specified vertical position is outside the region.
  • removeNoWriteRegion(): Remove the no-write area with the given index and rebuild the writable regions.
  • selectRegion(): Select the specified page region.
  • setCurrentPage(): Set the current page number (move to the specified page).
  • setNoWriteRegions(): Set the no-write page areas, replacing any previously stored areas for the page.
  • setPagePHeight(): Overrides the page height and returns the current value in points.
  • setPagePWidth(): Overrides the page width and returns the current value in points.
  • setX(): Set the absolute horizontal cursor position for the current region.
  • setY(): Set the absolute vertical cursor position for the current region.

From Settings