* Get or create the Info dictionary. * Creates a new Info dictionary if one doesn't exist.
()
| 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. |
no test coverage detected