Table of contents
Namespace: Com\Tecnick\Pdf\Sign\Output
final class Signature
Source: src/Output/Signature.php:45
Emits the /Sig value dictionary (the object referenced by a signature field’s /V): the fixed skeleton, the /SubFilter, and the /ByteRange and /Contents placeholders that the host rewrites while signing, plus the optional Name/Location/Reason/ContactInfo strings.
The /Reference (DocMDP or UR3 transform) and the /M date token are supplied by the caller as ready fragments, their content and formatting depending on host state (certification level, user rights, timezone, encryption). String encoding (escaping, UTF-16, encryption) of the info values is delegated to an injected encoder.
Constants
BYTE_RANGE_PLACEHOLDER
ByteRange placeholder rewritten by the host once the byte offsets are known.
public const BYTE_RANGE_PLACEHOLDER = '/ByteRange[0 ********** ********** **********]'
Source: src/Output/Signature.php:50
DEFAULT_CONTENTS_LENGTH
Default number of hex zero placeholder characters reserved for /Contents.
public const DEFAULT_CONTENTS_LENGTH = 11742
Source: src/Output/Signature.php:55
MAX_CONTENTS_LENGTH
Largest /Contents placeholder this emitter reserves, in hex characters.
The window holds one CMS signature or one RFC 3161 token, so a megabyte of hex is far beyond what either needs. Past it str_repeat() would exhaust memory rather than throw.
public const MAX_CONTENTS_LENGTH = 1048576
Source: src/Output/Signature.php:64
Methods
objectHead()
Emit the head of a signature value object, up to and including /Contents.
ISO 32000-2 section 12.8.5 gives a /Sig and a /DocTimeStamp the same shape: the Adobe.PPKLite filter, the ByteRange placeholder the host rewrites once it knows the offsets, and a /Contents window reserved as hex zeros. Emitted here for both.
public static objectHead(
int $objectId,
string $type,
string $subFilter,
int $contentsLength,
string $label
): string
Parameters:
$objectId(int): Object number for the value object.$type(string): /Type name, without the leading solidus.$subFilter(string): /SubFilter name, without the leading solidus.$contentsLength(int): Placeholder length reserved for the signature, in hex digits; must be even and positive.$label(string): Name of the object, for the error message.
Returns: string
Throws:
- Exception: If a name, the object number, or the placeholder length is invalid.
Source: src/Output/Signature.php:142
valueObject()
Emit the /Sig value object.
public valueObject(
int $objectId,
string $subFilter,
string $reference,
array<string,string> $info,
string $dateValue,
int $contentsLength = \self::DEFAULT_CONTENTS_LENGTH,
callable|null $stringEncoder = null
): string
Parameters:
$objectId(int): Object number for the /Sig value object.$subFilter(string): e.g. “ETSI.CAdES.detached” or “adbe.pkcs7.detached”.$reference(string): Ready /Reference fragment (DocMDP or UR3 transform), leading space included, or ’’ for an approval signature.$info(array<string,string>): Optional Name/Location/Reason/ContactInfo.$dateValue(string): Ready (already encoded) PDF string token for /M, or ’’ to omit the entry.$contentsLength(int): Placeholder length for /Contents, in hex digits; must be even and positive.$stringEncoder(callable|null): fn(string $text, int $objectId): string returning a PDF string token.
Returns: string
Throws:
- Exception: If the object number, the /SubFilter, an info value, or the placeholder length is invalid, or the string encoder returns a non-string value.
Source: src/Output/Signature.php:91