Table of contents
Namespace: Com\Tecnick\Pdf
Extends: CSS
Abstract: Yes
File: JavaScript.php line 53
JavaScript PDF class
Tags
- since: 2002-08-03
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2002-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-pdf
- phpstan-import-type: TAnnotOpts from \Com\Tecnick\Pdf\Base
- phpstan-import-type: TGTransparency from \Com\Tecnick\Pdf\Base
- phpstan-import-type: TXOBject from \Com\Tecnick\Pdf\Base
- phpstan-type: TRadioButtonItem array{ ’n’: int, ‘def’: string, }
- phpstan-type: TRadioButton array{ ’n’: int, ‘#readonly#’: bool, ‘kids’: array
, } - SuppressWarnings: (“PHPMD.DepthOfInheritance”)
Constants
BORDERPOS_DEFAULT
File: Base.php line 1405
public mixed BORDERPOS_DEFAULT = 0.0
BORDERPOS_EXTERNAL
File: Base.php line 1411
public mixed BORDERPOS_EXTERNAL = -0.5
BORDERPOS_INTERNAL
File: Base.php line 1417
public mixed BORDERPOS_INTERNAL = 0.5
ZEROCELL
File: Base.php line 1436
public TCellDef ZEROCELL = ['margin' => self::ZEROCELLBOUND, 'padding' => self::ZEROCELLBOUND, 'borderpos' => self::BORDERPOS_DEFAULT]
ZEROCELLBOUND
File: Base.php line 1424
public TCellBound ZEROCELLBOUND = ['T' => 0.0, 'R' => 0.0, 'B' => 0.0, 'L' => 0.0]
Properties
$barcode
File: Base.php line 732
public Barcode $barcode
$cache
File: Base.php line 747
public Cache $cache
$color
File: Base.php line 727
public PdfColor $color
$encrypt
File: Base.php line 722
public Encrypt $encrypt
$file
File: Base.php line 737
public File $file
$font
File: Base.php line 773
public Stack $font
$graph
File: Base.php line 768
public Draw $graph
$image
File: Base.php line 778
public Import $image
$markupFile
File: Base.php line 742
public File $markupFile
$page
File: Base.php line 763
public Page $page
$pon
File: Base.php line 1148
public int $pon = 0
$uniconv
File: Base.php line 758
public Convert $uniconv
Methods
addArtifactContent()
File: Text.php line 1036
public addArtifactContent(string $content, int $pid[, string $type = '' ][, string $subtype = '' ]) : void
This is the preferred API for decorative graphics and page furniture because it writes the wrapped content directly to the selected page.
Parameters
- $content : string: Raw PDF operators to wrap.
- $pid : int: Page index.
- $type : string = ‘’: Optional Artifact /Type (for example ‘Pagination’).
- $subtype : string = ‘’: Optional Artifact /Subtype (for example ‘Header’ or ‘Footer’).
Tags
- throws: Exception
addContentAsEmbeddedFile()
File: JavaScript.php line 772
public addContentAsEmbeddedFile(string $file, string $content[, string $mime = 'application/octet-stream' ][, string|AFRelationship $afrel = 'Source' ][, string $desc = '' ]) : void
If a file with the same name already exists, it will be ignored.
Parameters
- $file : string: File name to be used a key for the embedded file.
- $content : string: Content of the embedded file.
- $mime : string = ‘application/octet-stream’: MIME type of the file (e.g., ‘application/xml’).
- $afrel : string|AFRelationship = ‘Source’: AFRelationship value (Source, Data, Alternative, Supplement, Unspecified) or enum.
- $desc : string = ‘’: Optional description of the file.
Tags
- throws: Exception in case of error.
addEmbeddedFile()
File: JavaScript.php line 721
public addEmbeddedFile(string $file[, string $mime = 'application/octet-stream' ][, string|AFRelationship $afrel = 'Source' ][, string $desc = '' ]) : void
If a file with the same name already exists, it will be ignored.
Parameters
- $file : string: File name (absolute or relative path).
- $mime : string = ‘application/octet-stream’: MIME type of the file (e.g., ‘application/xml’).
- $afrel : string|AFRelationship = ‘Source’: AFRelationship value (Source, Data, Alternative, Supplement, Unspecified) or enum.
- $desc : string = ‘’: Optional description of the file.
Tags
- throws: Exception in case of error.
addFFButton()
File: JavaScript.php line 1501
public addFFButton(string $name, float $posx, float $posy, float $width, float $height, string $caption, string|array<string, mixed> $action[, TAnnotOpts $opt = ['subtype' => 'Widget'] ][, array<string, mixed> $jsp = [] ]) : int
Parameters
- $name : string: field name.
- $posx : float: horizontal position in user units (LTR).
- $posy : float: vertical position in user units (LTR).
- $width : float: width in user units.
- $height : float: height in user units.
- $caption : string: caption.
- $action : string|array<string, mixed>: action triggered by pressing the button. Use a string to specify a javascript action. Use an array to specify a form action options as in section 12.7.5 of PDF32000_2008.
- $opt : TAnnotOpts = [‘subtype’ => ‘Widget’]: Array of options (Annotation Types) - all lowercase.
- $jsp : array<string, mixed> = []: javascript field properties (see: Javascript for Acrobat API reference).
Tags
- throws: Exception in case of error.
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
Return values
int —
PDF Object ID.
addFFCheckBox()
File: JavaScript.php line 1662
public addFFCheckBox(string $name, float $posx, float $posy, float $width[, string $onvalue = 'Yes' ][, bool $checked = false ][, TAnnotOpts $opt = ['subtype' => 'Widget'] ][, array<string, mixed> $jsp = [] ]) : int
Parameters
- $name : string: field name.
- $posx : float: horizontal position in user units (LTR).
- $posy : float: vertical position in user units (LTR).
- $width : float: width in user units.
- $onvalue : string = ‘Yes’: Value to be returned if selected.
- $checked : bool = false: Define the initial state.
- $opt : TAnnotOpts = [‘subtype’ => ‘Widget’]: Array of options (Annotation Types) - all lowercase.
- $jsp : array<string, mixed> = []: javascript field properties (see: Javascript for Acrobat API reference).
Tags
- throws: Exception in case of error.
- throws: Exception
- throws: Exception
- throws: Exception
Return values
int —
PDF Object ID.
addFFComboBox()
File: JavaScript.php line 1739
public addFFComboBox(string $name, float $posx, float $posy, float $width, float $height, array<string|int, array{string, string}>|array<string|int, string> $values[, TAnnotOpts $opt = ['subtype' => 'Widget'] ][, array<string, mixed> $jsp = [] ]) : int
Parameters
- $name : string: field name.
- $posx : float: horizontal position in user units (LTR).
- $posy : float: vertical position in user units (LTR).
- $width : float: width in user units.
- $height : float: height in user units.
- $values : array<string|int, array{string, string}>|array<string|int, string>: List of selection values.
- $opt : TAnnotOpts = [‘subtype’ => ‘Widget’]: Array of options (Annotation Types) - all lowercase.
- $jsp : array<string, mixed> = []: javascript field properties (see: Javascript for Acrobat API reference).
Tags
- throws: Exception in case of error.
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
Return values
int —
PDF Object ID.
addFFListBox()
File: JavaScript.php line 1812
public addFFListBox(string $name, float $posx, float $posy, float $width, float $height, array<string|int, array{string, string}>|array<string|int, string> $values[, TAnnotOpts $opt = ['subtype' => 'Widget'] ][, array<string, mixed> $jsp = [] ]) : int
Parameters
- $name : string: field name.
- $posx : float: horizontal position in user units (LTR).
- $posy : float: vertical position in user units (LTR).
- $width : float: width in user units.
- $height : float: height in user units.
- $values : array<string|int, array{string, string}>|array<string|int, string>: List of selection values.
- $opt : TAnnotOpts = [‘subtype’ => ‘Widget’]: Array of options (Annotation Types) - all lowercase.
- $jsp : array<string, mixed> = []: javascript field properties (see: Javascript for Acrobat API reference).
Tags
- throws: Exception in case of error.
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
Return values
int —
PDF Object ID.
addFFRadioButton()
File: JavaScript.php line 1882
public addFFRadioButton(string $name, float $posx, float $posy, float $width[, string $onvalue = 'On' ][, bool $checked = false ][, TAnnotOpts $opt = ['subtype' => 'Widget'] ][, array<string, mixed> $jsp = [] ]) : int
Parameters
- $name : string: field name.
- $posx : float: horizontal position in user units (LTR).
- $posy : float: vertical position in user units (LTR).
- $width : float: width in user units.
- $onvalue : string = ‘On’: Value to be returned if selected.
- $checked : bool = false: Define the initial state.
- $opt : TAnnotOpts = [‘subtype’ => ‘Widget’]: Array of options (Annotation Types) - all lowercase.
- $jsp : array<string, mixed> = []: javascript field properties (see: Javascript for Acrobat API reference).
Tags
- throws: Exception in case of error.
- throws: Exception
- throws: Exception
- throws: Exception
Return values
int —
PDF Object ID.
addFFText()
File: JavaScript.php line 1982
public addFFText(string $name, float $posx, float $posy, float $width, float $height[, TAnnotOpts $opt = ['subtype' => 'text'] ][, array<string, mixed> $jsp = [] ]) : int
Parameters
- $name : string: field name.
- $posx : float: horizontal position in user units (LTR).
- $posy : float: vertical position in user units (LTR).
- $width : float: width in user units.
- $height : float: height in user units.
- $opt : TAnnotOpts = [‘subtype’ => ’text’]: Array of options (Annotation Types) - all lowercase.
- $jsp : array<string, mixed> = []: javascript field properties (see: Javascript for Acrobat API reference).
Tags
- throws: Exception in case of error.
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
- throws: Exception
Return values
int —
PDF Object ID.
addGlobalCSS()
File: CSS.php line 223
public addGlobalCSS(string $css) : void
Parameters
- $css : string: CSS content without surrounding