* Create a PdfString from text (auto-selects encoding). * * Uses PDFDocEncoding if all characters fit, otherwise UTF-16BE with BOM. * PDFDocEncoding supports ASCII, Latin-1 supplement, and some special chars * (€, •, —, ", ", etc.). For CJK, emoji, or other Unicode, uses UTF-16BE.
(text: string)
| 42 | * (€, •, —, ", ", etc.). For CJK, emoji, or other Unicode, uses UTF-16BE. |
| 43 | */ |
| 44 | static fromString(text: string): PdfString { |
| 45 | const bytes = encodeTextString(text); |
| 46 | // Use hex format for UTF-16 (has BOM, cleaner output), literal for PDFDoc |
| 47 | const format = canEncodePdfDoc(text) ? "literal" : "hex"; |
| 48 | return new PdfString(bytes, format); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Create a PdfString from a hex string (e.g., "48656C6C6F"). |
nothing calls this directly
no test coverage detected