PdfString

Encodes a text value as a PDF string token, either through a host-supplied encoder (which may apply UTF-16, escaping, and encryption) or, when none is given, a built-in fallback.

Table of contents

Namespace: Com\Tecnick\Pdf\Sign\Output

Final: Yes

File: PdfString.php line 44

Encodes a text value as a PDF string token, either through a host-supplied encoder (which may apply UTF-16, escaping, and encryption) or, when none is given, a built-in fallback.

The fallback emits a literal string for printable ASCII, escaping the three delimiters. Everything else is emitted as a UTF-16BE hex string with a byte order mark: raw bytes above 0x7E in a literal string are read as PDFDocEncoding and render as mojibake, and a raw CR or CRLF is folded into a single LF (ISO 32000-1 section 7.3.4.2). The hex form has neither problem.

Tags

Methods

encode()

File: PdfString.php line 64

public static encode(string $text, int $objectId[, callable|null $encoder = null ]) : string

Parameters

  • $text : string
  • $objectId : int
  • $encoder : callable|null = null: fn(string $text, int $objectId): string

Tags

  • throws: Exception If the encoder returns a non-string value.

Return values

string