Base

Output PDF data

Namespace: Com\Tecnick\Pdf

abstract class Base

Source: src/Base.php:714

Output PDF data

Types

TViewerPref

array{
    'HideToolbar'?: bool,
    'HideMenubar'?: bool,
    'HideWindowUI'?: bool,
    'FitWindow'?: bool,
    'CenterWindow'?: bool,
    'DisplayDocTitle'?: bool,
    'NonFullScreenPageMode'?: string,
    'Direction'?: string,
    'ViewArea'?: string,
    'ViewClip'?: string,
    'PrintArea'?: string,
    'PrintClip'?: string,
    'PrintScaling'?: string,
    'Duplex'?: string,
    'PickTrayByPDFSize'?: bool,
    'PrintPageRange'?: array<int>,
    'NumCopies'?: int,
}

TBBox

array{
    'x': float, // left position
    'y': float, // top position
    'w': float, // width
    'h': float, // height
}

TStackUnitBBox

array<int, TBBox>

TStackTextBBox

array<int, TBBox>

TStackCellBBox

array<int, TBBox>

Cell side values (Top, Right, Bottom, Left) in internal points.

TCellBound

array{
    'T': float,
    'R': float,
    'B': float,
    'L': float,
}

Cell definition.

The 'margin' and 'padding' values are expressed in internal points and not in
user units: use toPoints() to convert them from the current unit.
The setDefaultCellMargin() and setDefaultCellPadding() methods take user units
and perform the conversion internally.

TCellDef

array{
    'margin': TCellBound,
    'padding': TCellBound,
    'borderpos': float,
}

TRefUnitValues

array{
   'parent': float,
   'font': array{
      'rootsize': float,
      'size': float,
      'xheight': float,
      'zerowidth': float,
   },
   'viewport': array{
      'width': float,
      'height': float,
   },
   'page': array{
      'width': float,
      'height': float,
   },
}

TCustomXMP

array{
   'x:xmpmeta': string,
   'x:xmpmeta.rdf:RDF': string,
   'x:xmpmeta.rdf:RDF.rdf:Description': string,
   'x:xmpmeta.rdf:RDF.rdf:Description.pdfaExtension:schemas': string,
   'x:xmpmeta.rdf:RDF.rdf:Description.pdfaExtension:schemas.rdf:Bag': string,
}

THybridDoc

array{
   'filename': string,
   'doctype': string,
   'version': string,
   'conformance': string,
   'uri': string,
   'prefix': string,
   'schema': string,
}

TXMPProperties

list<array{
   category: string,
   description: string,
   name: string,
   valueType: string,
}>

TPdfUaStructKid

array{
   type: 'elem'|'mcid',
   id: int,
   pid?: int,
}

TPdfUaStructElem

array{
   role: string,
   pid: int,
   mcids: int[],
   kids: TPdfUaStructKid[],
   alt?: string,
   annots?: int[],
   attr?: array<string, string>,
   bbox?: TFourFloat,
   refpid?: int,
   required?: bool,
}

TFileOptions

array{
  allowedHosts?: array<string>,
  maxRemoteSize?: int,
  curlopts?: array<int, bool|int|string>,
  defaultCurlOpts?: array<int, bool|int|string>,
  fixedCurlOpts?: array<int, bool|int|string>,
  allowedPaths?: array<string>,
  markupAllowedPaths?: array<string>
}

TFourFloat

array{
    float,
    float,
    float,
    float,
}

TAnnotQuadPoint

array{
    float,
    float,
    float,
    float,
    float,
    float,
    float,
    float,
}

TAnnotBorderStyle

array{
    'type'?: string,
    'w': int,
    's': string,
    'd'?: array<int>,
}

TAnnotBorderEffect

array{
    's'?: string,
    'i'?: float,
}

TAnnotMeasure

array{
    'type'?: string,
    'subtype'?: string,
}

TAnnotMarkup

array{
    't'?: string,
    'popup'?: array<mixed>,
    'ca'?: float,
    'rc'?: string,
    'creationdate'?: string,
    'irt'?: array<mixed>,
    'subj'?: string,
    'rt'?: string,
    'it'?: string,
    'exdata'?: array{
  'type'?: string,
  'subtype': string,
    },
}

TAnnotStates

array{
    'marked'?: string,
    'review'?: string,
}

TAnnotText

array{
    'subtype': string,
    'open'?: bool,
    'name'?: string,
    'state'?: string,
    'statemodel'?: string,
}

TUriAction

array{
   's': string,
   'uri': string,
   'ismap'?: bool,
}

TAnnotActionDict

array{
    'type'?: string,
    's'?: string,
    'next'?: array<int, array<mixed>>,
}

TAnnotAdditionalActionDict

array{
    'e'?: TAnnotActionDict,
    'x'?: TAnnotActionDict,
    'd'?: TAnnotActionDict,
    'u'?: TAnnotActionDict,
    'fo'?: TAnnotActionDict,
    'bi'?: TAnnotActionDict,
    'po'?: TAnnotActionDict,
    'pc'?: TAnnotActionDict,
    'pv'?: TAnnotActionDict,
    'pi'?: TAnnotActionDict,
}
array{
    'subtype': string,
    'a'?: TAnnotActionDict,
    'dest'?: string|array<mixed>,
    'h'?: string,
    'pa'?: TUriAction,
    'quadpoints'?: array<int, TAnnotQuadPoint>,
    'bs'?: TAnnotBorderStyle,
}

TAnnotFreeText

array{
    'subtype': string,
    'da': string,
    'q'?: int,
    'rc'?: string,
    'ds'?: string,
    'cl'?: array<float>,
    'it'?: string,
    'be'?: TAnnotBorderEffect,
    'rd'?: TFourFloat,
    'bs'?: TAnnotBorderStyle,
    'le'?: string,
}

TAnnotLine

array{
    'subtype': string,
    'l': TFourFloat,
    'bs'?: TAnnotBorderStyle,
    'le'?: array{
        string,
        string
    },
    'ic'?: TFourFloat,
    'll'?: float,
    'lle'?: float,
    'cap'?: bool,
    'it'?: string,
    'llo'?: float,
    'cp'?: string,
    'measure'?: TAnnotMeasure,
    'co'?: array{
        float,
        float
    },
}

TAnnotSquare

array{
    'subtype': string,
    'bs'?: TAnnotBorderStyle,
    'ic'?: TFourFloat,
    'be'?: TAnnotBorderEffect,
    'rd'?: TFourFloat,
}

TAnnotCircle

TAnnotSquare

TAnnotPolygon

array{
    'subtype': string,
    'vertices'?: array<float>,
    'le'?: array{
        string,
        string
    },
    'bs'?: TAnnotBorderStyle,
    'ic'?: TFourFloat,
    'be'?: TAnnotBorderEffect,
    'it'?: string,
    'measure'?: TAnnotMeasure,
}

TAnnotPolyline

TAnnotPolygon

TAnnotTextMarkup

array{
    'subtype': string,
    'quadpoints': array<int, TAnnotQuadPoint>,
}

TAnnotCaret

array{
    'subtype': string,
    'rd'?: TFourFloat,
    'sy'?: string,
}

TAnnotRubberStamp

array{
    'subtype': string,
    'name'?: string,
}

TAnnotInk

array{
    'subtype': string,
    'inklist'?: array<int, array<float>>,
    'bs'?: TAnnotBorderStyle,
}

TAnnotPopup

array{
    'subtype': string,
    'parent'?: array<mixed>,
    'open'?: bool,
}

TAnnotFileAttachment

array{
    'subtype': string,
    'fs'?: string,
    'name'?: string,
}

TAnnotSound

array{
    'subtype': string,
    'sound': string,
    'name'?: string,
}

TAnnotMovieDict

array{
    'f': string,
    'aspect'?: array{
        float,
        float
    },
    'rotate'?: int,
    'poster'?: bool|string,
}

TAnnotMovieActDict

array{
    'start'?: int|string|array{
        int|string,
        int
    },
    'duration'?: int|string|array{
        int|string,
        int
    },
    'rate'?: float,
    'volume'?: float,
    'showcontrols'?: bool,
    'mode'?: string,
    'synchronous'?: bool,
    'fwscale'?: array{
        int,
        int
    },
    'fwposition'?: array{
        float,
        float
    },
}

TAnnotMovie

array{
    'subtype': string,
    't'?: string,
    'movie'?: TAnnotMovieDict,
    'a'?: bool|TAnnotMovieActDict,
}

TAnnotIconFitDict

array{
    'sw'?: string,
    's'?: string,
    'a'?: array{
        float,
        float
    },
    'fb'?: bool,
}

TAnnotMKDict

array{
    'r'?: int,
    'bc'?: TFourFloat,
    'bg'?: array{float},
    'ca'?: string,
    'rc'?: string,
    'ac'?: string,
    'i'?: string,
    'ri'?: string,
    'ix'?: string,
    'if'?: TAnnotIconFitDict,
    'tp'?: int,
}

TAnnotScreen

array{
    'subtype': string,
    't'?: string,
    'mk'?: TAnnotMKDict,
    'a'?: TAnnotActionDict,
    'aa'?: TAnnotAdditionalActionDict,
}

TAnnotWidget

array{
    'subtype': string,
    'h'?: string,
    'mk'?: array<array-key, mixed>,
    'a'?: TAnnotActionDict|string,
    'aa'?: TAnnotAdditionalActionDict|string,
    'bs'?: TAnnotBorderStyle,
    'parent'?: array<mixed>,
    'border'?: array<mixed>,
    'f'?: int,
    'ff'?: int|array<int, int>,
    'dv'?: mixed,
    'v'?: mixed,
    'rv'?: mixed,
    't'?: string,
    'tm'?: string,
    'tu'?: string,
    'i'?: array<mixed>,
    'opt'?: array<int, string|array{mixed, string}>,
    'maxlen'?: int,
    'da'?: string,
}

TAnnotFixedPrintDict

array{
    'type': string,
    'matrix'?: array{
        float,
        float,
        float,
        float,
        float,
        float
    },
    'h'?: float,
    'v'?: float,
}

TAnnotWatermark

array{
    'subtype': string,
    'fixedprint'?: TAnnotFixedPrintDict,
}

TAnnotRedact

array{
    'subtype': string,
    'quadpoints'?: array<int, TAnnotQuadPoint>,
    'ic'?: TFourFloat,
    'ro'?: string,
    'overlaytext'?: string,
    'repeat'?: bool,
    'da'?: string,
    'q'?: int,
}

TAnnotOptsA

TAnnotText|TAnnotLink|TAnnotFreeText

TAnnotOptsB

TAnnotLine|TAnnotSquare|TAnnotCircle|TAnnotPolygon|TAnnotPolyline

TAnnotOptsC

TAnnotTextMarkup|TAnnotCaret|TAnnotRubberStamp|TAnnotInk|TAnnotPopup

TAnnotOptsD

TAnnotFileAttachment|TAnnotSound|TAnnotMovie

TAnnotOptsE

TAnnotScreen|TAnnotWidget|TAnnotWatermark|TAnnotRedact

TAnnotOpts

TAnnotOptsA|TAnnotOptsB|TAnnotOptsC|TAnnotOptsD|TAnnotOptsE

TAnnot

array{
    'n': int,
    'x': float,
    'y': float,
    'w': float,
    'h': float,
    'txt': string,
    'opt': TAnnotOpts,
}

TGTransparency

array{
    'CS': string,
    'I': bool,
    'K': bool,
}

TXOBject

array{
    'spot_colors': array<string>,
    'extgstate': array<int>,
    'gsnames': array<string>,
    'gradient': array<int>,
    'pattern': array<string>,
    'font': array<string>,
    'image': array<int>,
    'xobject': array<string>,
    'annotations': array<int, TAnnot>,
    'transparency'?: ?TGTransparency,
    'id': string,
    'outdata': string,
    'n': int,
    'x': float,
    'y': float,
    'w': float,
    'h': float,
    'pheight': float,
    'gheight': float,
}

TPatternObject

array{
    'id': string,
    'n': int,
    'outdata': string,
    'bbox': array{
        float,
        float,
        float,
        float
    },
    'xstep': float,
    'ystep': float,
    'matrix': array{
        float,
        float,
        float,
        float,
        float,
        float
    },
}

TSVGMaskObject

array{
    'id': string,
    'stream': string,
    'bbox': array{
        float,
        float,
        float,
        float
    },
    'gs_n': int,
}

TOutline

array{
    't': string,
    'u': string,
    'l': int,
    'p': int,
    'x': float,
    'y': float,
    's': string,
    'c': string,
    'parent': int,
    'last': int,
    'first': int,
    'prev': int,
    'next': int,
}

TLtvConfig

array{
    'enabled': bool,
    'embed_ocsp': bool,
    'embed_crl': bool,
    'embed_certs': bool,
    'include_dss': bool,
    'include_vri': bool,
}

TSignature

array{
    'appearance': array{
        'ap'?: string|array<string, string|array<string, string>>,
        'as'?: string,
        'empty': array<int, array{
            'objid': int,
            'name': string,
            'page': int,
            'rect': string,
            'tu'?: string,
        }>,
        'name': string,
        'page': int,
        'rect': string,
        'tu'?: string,
        'xobj'?: string,
    },
    'approval': string,
    'cert_type': int,
    'extracerts': ?string,
    'info': array{
        'ContactInfo': string,
        'Location': string,
        'Name': string,
        'Reason': string,
    },
    'password': string,
    'privkey': string,
    'signcert': string,
    'profile'?: string,
    'digest_algorithm'?: string,
    'ltv'?: TLtvConfig,
}

TSignTimeStamp

array{
    'enabled': bool,
    'host': string,
    'username': string,
    'password': string,
    'cert': string,
    'hash_algorithm': string,
    'policy_oid': string,
    'nonce_enabled': bool,
    'timeout': int,
    'verify_peer': bool,
    'allow_sha1'?: bool,
}

TUserRights

array{
    'annots': string,
    'document': string,
    'ef': string,
    'enabled': bool,
    'form': string,
    'formex': string,
    'signature': string,
}

TEmbeddedFile

array{
    'a': int,
    'f': int,
    'n': int,
    'file': string,
    'content': string,
    'mimeType': string,
    'afRelationship': string,
    'description': string,
    'creationDate': int,
    'modDate': int,
}

TObjID

array{
    'catalog': int,
    'dests': int,
    'doctimestamp': int,
    'dss': int,
    'form': array<int>,
    'info': int,
    'pages': int,
    'resdic': int,
    'signature': int,
    'srgbicc': int,
    'outputintenticc': int,
    'xmp': int,
}

TSignDocPrepared

array{
    'byte_range': array{
        int,
        int,
        int,
        int
    },
    'pdfdoc': string,
    'pdfdoc_length': int,
}

Constants

BORDERPOS_DEFAULT

The default relative position of the cell origin when the border is centered on the cell edge.

public const BORDERPOS_DEFAULT = 0.0

Source: src/Base.php:1411

BORDERPOS_EXTERNAL

The relative position of the cell origin when the border is external to the cell edge.

public const BORDERPOS_EXTERNAL = -0.5

Source: src/Base.php:1417

BORDERPOS_INTERNAL

The relative position of the cell origin when the border is internal to the cell edge.

public const BORDERPOS_INTERNAL = 0.5

Source: src/Base.php:1423

ZEROCELL

Default values for cell.

public const ZEROCELL = ['margin' => self::ZEROCELLBOUND, 'padding' => self::ZEROCELLBOUND, 'borderpos' => self::BORDERPOS_DEFAULT]

Source: src/Base.php:1442

ZEROCELLBOUND

Default values for cell boundaries.

public const ZEROCELLBOUND = ['T' => 0.0, 'R' => 0.0, 'B' => 0.0, 'L' => 0.0]

Source: src/Base.php:1430

Properties

$barcode

Barcode object.

public Barcode $barcode

Source: src/Base.php:734

$cache

Cache object.

public Cache $cache

Source: src/Base.php:749

$color

Color object.

public PdfColor $color

Source: src/Base.php:729

$encrypt

Encrypt object.

public Encrypt $encrypt

Source: src/Base.php:724

$file

File object.

public File $file

Source: src/Base.php:739

$font

Font object.

public Stack $font

Source: src/Base.php:775

$graph

Graph object.

public Draw $graph

Source: src/Base.php:770

$image

Image Import object.

public Import $image

Source: src/Base.php:780

$markupFile

File object for markup-originated resources.

public File $markupFile

Source: src/Base.php:744

$page

Page object.

public Page $page

Source: src/Base.php:765

$pon

Current PDF object number.

public int $pon = 0

Source: src/Base.php:1154

$uniconv

Unicode Convert object.

public Convert $uniconv

Source: src/Base.php:760

Methods

defaultFileAllowedPaths()

Returns the default array of allowed file paths.

public defaultFileAllowedPaths(): string[]

Returns: string[]

Source: src/Base.php:1651

defaultMarkupAllowedPaths()

Returns the default array of allowed file paths for markup-originated resources.

public defaultMarkupAllowedPaths(): string[]

Returns: string[]

Source: src/Base.php:1661

enableDefaultPageContent()

Enable or disable the default page content.

public enableDefaultPageContent(bool $enable = true): void

Parameters:

  • $enable (bool): Enable or disable the default page content.

Source: src/Base.php:1520

getWarnings()

Return the conformance warnings raised while the document was rendered.

The list is filled while the content is written and while the document is serialized, so it is complete only after getOutPDFString() has been called.

public getWarnings(): array<int,string>

Returns: array<int,string>

Source: src/Base.php:1866

initClassObjects()

Initialize dependencies class objects.

public initClassObjects(
    ?Encrypt $objEncrypt = null,
    TFileOptions|null $fileOptions = null,
    ?CacheInterface $cache = null
): void

Parameters:

  • $objEncrypt (?Encrypt): Encryption object.
  • $fileOptions (TFileOptions|null): Optional configuration for the shared file helper used to load external resources (images, fonts, SVG, etc.). Supported keys:
    • allowedHosts (string[]): Whitelist of host names that the library is allowed to fetch over HTTP/HTTPS. For security reasons remote URL loading is DISABLED by default; you MUST populate this list (for example [’example.com’, ‘cdn.example.com’]) to enable any remote download. Local file reads are controlled separately by allowedPaths.
    • maxRemoteSize (int): Maximum size in bytes accepted for a remote download (default 52428800 = 50 MiB).
    • curlopts (array<int,bool|int|string>): Per-request cURL options merged on top of the defaults (keys are CURLOPT_* constants).
    • defaultCurlOpts (array<int,bool|int|string>): Replaces the built-in default cURL options. Use with care; omit to keep the safe defaults.
    • fixedCurlOpts (array<int,bool|int|string>): cURL options that are always enforced and cannot be overridden by curlopts (for example to pin TLS settings).
    • allowedPaths (string[]): Trusted local path prefixes for file:// reads. Defaults are automatically computed from the package location to cover bundled example assets.
    • markupAllowedPaths (string[]): Trusted local path prefixes for resources referenced by rendered HTML/CSS/SVG markup. Defaults exclude the system temp directory; when omitted, explicit allowedPaths values are reused for markup too.
  • $cache (?CacheInterface): Optional external cache shared by the cacheable sub-libraries (font subsets, images, …). The application owns the backend, its (de)serialization, expiration and size limits. Null (default) disables external caching.

Throws:

Source: src/Base.php:2081

setPDFVersion()

Set the PDF version (check PDF reference for valid values).

public setPDFVersion(string $version = '1.7'): static

Parameters:

  • $version (string): PDF document version.

Returns: static

Throws:

Source: src/Base.php:1985

setRTL()

Set the default document language direction.

public setRTL(bool $enabled): static

Parameters:

  • $enabled (bool): False = LTR = Left-To-Right; True = RTL = Right-To-Left.

Returns: static

Source: src/Base.php:1630

toPoints()

Convert user units to internal points unit.

public toPoints(float $usr): float

Parameters:

  • $usr (float): Value to convert.

Returns: float

Source: src/Base.php:1460

toUnit()

Convert internal points to user unit.

public toUnit(float $pnt): float

Parameters:

  • $pnt (float): Value to convert in user units.

Returns: float

Source: src/Base.php:1470

toYPoints()

Convert vertical user value to internal points unit.

Note: the internal Y points coordinate starts at the bottom left of the page.

public toYPoints(float $usr, float $pageh = -1): float

Parameters:

  • $usr (float): Value to convert.
  • $pageh (float): Optional page height in internal points ($pageh:$this->page->getPage()[‘pheight’]).

Returns: float

Throws:

Source: src/Base.php:1484

toYUnit()

Convert vertical internal points value to user unit.

Note: the internal Y points coordinate starts at the bottom left of the page.

public toYUnit(float $pnt, float $pageh = -1): float

Parameters:

  • $pnt (float): Value to convert.
  • $pageh (float): Optional page height in internal points ($pageh:$this->page->getPage()[‘pheight’]).

Returns: float

Throws:

Source: src/Base.php:1503