MCPcopy Create free account
hub / github.com/LibPDF-js/core / buildNameTree

Function buildNameTree

src/document/name-tree.ts:313–329  ·  view source on GitHub ↗
(entries: Array<[string, PdfRef]>)

Source from the content-addressed store, hash-verified

311 * @returns A PdfDict representing the name tree root
312 */
313export function buildNameTree(entries: Array<[string, PdfRef]>): PdfDict {
314 // Sort entries by key (lexicographic)
315 const sorted = [...entries].sort((a, b) => compareKeys(a[0], b[0]));
316
317 // Build flat /Names array: [key1, ref1, key2, ref2, ...]
318 const namesArray: PdfObject[] = [];
319
320 for (const [key, ref] of sorted) {
321 namesArray.push(PdfString.fromString(key));
322 namesArray.push(ref);
323 }
324
325 const dict = new PdfDict();
326 dict.set("Names", new PdfArray(namesArray));
327
328 return dict;
329}

Callers 3

name-tree.test.tsFile · 0.90
addMethod · 0.90
removeMethod · 0.90

Calls 4

setMethod · 0.95
compareKeysFunction · 0.85
pushMethod · 0.80
fromStringMethod · 0.45

Tested by

no test coverage detected