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

Method getFileId

src/parser/document-parser.ts:883–897  ·  view source on GitHub ↗

* Extract the file ID from the trailer's /ID array. * Returns the first element of the array (the permanent file ID).

(trailer: PdfDict)

Source from the content-addressed store, hash-verified

881 * Returns the first element of the array (the permanent file ID).
882 */
883 private getFileId(trailer: PdfDict): Uint8Array | null {
884 const idArray = trailer.getArray("ID");
885
886 if (!idArray || idArray.length < 1) {
887 return null;
888 }
889
890 const firstId = idArray.at(0);
891
892 if (firstId instanceof PdfString) {
893 return firstId.bytes;
894 }
895
896 return null;
897 }
898
899 /**
900 * Check if bytes at position match a pattern.

Callers 1

buildDocumentMethod · 0.95

Calls 2

getArrayMethod · 0.80
atMethod · 0.80

Tested by

no test coverage detected