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

Method getInfoDict

src/api/pdf.ts:1011–1043  ·  view source on GitHub ↗

* Get or create the Info dictionary. * Creates a new Info dictionary if one doesn't exist.

()

Source from the content-addressed store, hash-verified

1009 * Creates a new Info dictionary if one doesn't exist.
1010 */
1011 private getInfoDict(): PdfDict {
1012 if (this._infoDict) {
1013 return this._infoDict;
1014 }
1015
1016 const infoRef = this.ctx.info.trailer.getRef("Info");
1017
1018 if (infoRef) {
1019 const existing = this.ctx.registry.getObject(infoRef);
1020
1021 if (existing instanceof PdfDict) {
1022 this._infoDict = existing;
1023
1024 return this._infoDict;
1025 }
1026 }
1027
1028 // Create new Info dictionary
1029 const infoDict = new PdfDict([
1030 ["Title", PdfString.fromString("Untitled")],
1031 ["Author", PdfString.fromString("Unknown")],
1032 ["Creator", PdfString.fromString("@libpdf/core")],
1033 ["Producer", PdfString.fromString("@libpdf/core")],
1034 ["CreationDate", PdfString.fromString(formatPdfDate(new Date()))],
1035 ["ModDate", PdfString.fromString(formatPdfDate(new Date()))],
1036 ]);
1037
1038 const newRef = this.ctx.registry.register(infoDict);
1039 this.ctx.info.trailer.set("Info", newRef);
1040 this._infoDict = infoDict;
1041
1042 return this._infoDict;
1043 }
1044
1045 /**
1046 * Get the document title.

Callers 9

setTitleMethod · 0.95
setAuthorMethod · 0.95
setSubjectMethod · 0.95
setKeywordsMethod · 0.95
setCreatorMethod · 0.95
setProducerMethod · 0.95
setCreationDateMethod · 0.95
setModificationDateMethod · 0.95
setTrappedMethod · 0.95

Calls 6

formatPdfDateFunction · 0.90
getObjectMethod · 0.65
getRefMethod · 0.45
fromStringMethod · 0.45
registerMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected