setasign\SetaPDF2\Core\Document

Destination Class for handling Destinations in a PDF document

File: /SetaPDF v2/Core/Document/Destination.php
Old class name (alias): \SetaPDF_Core_Document_Destination

Class hierarchy

Summary

Constants

FIT_MODE_FIT

public const Destination::FIT_MODE_FIT = 'Fit'

Fit mode constant.

Display the page designated by page, with its contents magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the page within the window in the other dimension.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_FIT_B

public const Destination::FIT_MODE_FIT_B = 'FitB'

Fit mode constant.

Display the page designated by page, with its contents magnified just enough to fit its bounding box entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the bounding box within the window in the other dimension.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_FIT_BH

public const Destination::FIT_MODE_FIT_BH = 'FitBH'

Fit mode constant.

Display the page designated by page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of its bounding box within the window. A null value for top specifies that the current value of that parameter shall be retained unchanged.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_FIT_BV

public const Destination::FIT_MODE_FIT_BV = 'FitBV'

Fit mode constant.

Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of its bounding box within the window. A null value for left specifies that the current value of that parameter shall be retained unchanged.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_FIT_H

public const Destination::FIT_MODE_FIT_H = 'FitH'

Fit mode constant.

Display the page designated by page, with the vertical coordinate toppositioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of the page within the window. A null value for top specifies that the current value of that parameter shall be retained unchanged.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_FIT_R

public const Destination::FIT_MODE_FIT_R = 'FitR'

Fit mode constant.

Display the page designated by page, with its contents magnified just enough to fit the rectangle specified by the coordinates left, bottom, right, and top entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the rectangle within the window in the other dimension.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_FIT_V

public const Destination::FIT_MODE_FIT_V = 'FitV'

Fit mode constant.

Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of the page within the window. A null value for left specifies that the current value of that parameter shall be retained unchanged.
See
  • PDF 32000-1:2008 - Table 151

FIT_MODE_XYZ

public const Destination::FIT_MODE_XYZ = 'XYZ'

Fit mode constant.

Display the page designated by page, with the coordinates (left, top) positioned at the upper-left corner of the window and the contents of the page magnified by the factor zoom. A null value for any of the parameters left, top, or zoom specifies that the current value of that parameter shall be retained unchanged. A zoom value of 0 has the same meaning as a null value.
See
  • PDF 32000-1:2008 - Table 151

Properties

$_destination

The destination array


Static Methods

_handleFitModeParameter()

Handle the fitMode parameter and set the correct values in the resulting array.

Parameters
$array : \SetaPDF_Core_Type_Array
 
$fitMode : string
 

createByPage()

Creates a destination by a page object.

All additional arguments are passed to the createDestinationArray() method.

Parameters
$page : \SetaPDF_Core_Document_Page
 
See

createByPageNo()

Creates a destination by page number.

All additional arguments are passed to the createDestinationArray() method.

Example:

$destinationArray = \SetaPDF_Core_Document_Destination::createByPageNo(
    $document, 123, \SetaPDF_Core_Document_Destination::FIT_MODE_XYZ, 30, 50, 200
);
Parameters
$document : \SetaPDF_Core_Document
 
$pageNumber : int
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See

createDestinationArray()

Creates an explicit Destination array.

This method allows you to pass a flexible argument count after the $fitMode parameter, depending on its value. Following fit modes expect following arguments:

Destination::FIT_MODE_XYZ

float|null $left, float|null $top, float|null $zoom

Destination::FIT_MODE_FIT

- no parameter -

Destination::FIT_MODE_FIT_H

float|null $top

Destination::FIT_MODE_FIT_V

float|null $left

Destination::FIT_MODE_FIT_R

float $left, float $bottom, float $right, float $top

Destination::FIT_MODE_FIT_B

- no parameter -

Destination::FIT_MODE_FIT_BH

float|null $top

Destination::FIT_MODE_FIT_BV

float|null $left

Example:

$destinationArray = \SetaPDF_Core_Document_Destination::createDestinationArray(
    $indirectObject, \SetaPDF_Core_Document_Destination::FIT_MODE_XYZ, 30, 50, 200
);

It is also possible to pass a single array to the $fitMode parameter with all data:

$destinationArray = \SetaPDF_Core_Document_Destination::createDestinationArray(
    $indirectObject, [\SetaPDF_Core_Document_Destination::FIT_MODE_XYZ, 30, 50, 200]
);
Parameters
$pageObject : \SetaPDF_Core_Type_IndirectObject|\SetaPDF_Core_Type_Numeric

The indirect object of a page of or the page number for the usage in remote go-to actions.

$fitMode : string|array

The fit mode or an array with the fit mode and all additional arguments

Exceptions

Throws \InvalidArgumentException

findByName()

public static Destination::findByName (
\SetaPDF_Core_Document $document,
string $name
): bool|\SetaPDF_Core_Document_Destination

Find a destination by a name.

Parameters
$document : \SetaPDF_Core_Document
 
$name : string
 
Return Values

The destination object or false if it was not found.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception


Methods

__construct()

The constructor.

Parameters
$destination : \SetaPDF_Core_Type_AbstractType
 
Exceptions

Throws \InvalidArgumentException

getDestinationArray()

Get the destination array.

getFitMode()

public Destination::getFitMode (
void
): array

Get the fit mode and its parameters.

Return Values

Index 0 is the fit mode, all other values are the individual parameters of the fit mode.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getIndirectObject()

Get the indirect object of this destination or creates it in the specific document context.

Parameters
$document : ?\SetaPDF_Core_Document

The document instance

getPageNo()

public Destination::getPageNo (): int|false

Get the target page number.

Parameters
$document : \SetaPDF_Core_Document
 
Exceptions

Throws ObjectNotDefinedException

Throws ObjectNotFoundException

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getPdfValue()

Get the PDF value of this destination.

setFitMode()

public Destination::setFitMode (
string|array $fitMode
): void

Set the fit mode.

Parameters
$fitMode : string|array
 
See