mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-26 00:47:21 +02:00
Name-tree keys are PDF text strings, so encode named destinations with stringToAsciiOrUTF16BE when writing the /Dests tree; otherwise a non-ASCII name (e.g. "名") is truncated to a single byte and lost on round-trip. Sort the name/number tree by byte value rather than localeCompare, matching the order used when the tree is read back. Apply the same encoding to deduplicated /EmbeddedFiles names: those are rebuilt from a decoded display string, so a non-ASCII attachment name would otherwise be corrupted when its duplicate is written.