* Get the document title. * * @returns The title, or undefined if not set * * @example * ```typescript * const title = pdf.getTitle(); * if (title) { * console.log(`Document: ${title}`); * } * ```
()
| 1056 | * ``` |
| 1057 | */ |
| 1058 | getTitle(): string | undefined { |
| 1059 | const infoRef = this.ctx.info.trailer.getRef("Info"); |
| 1060 | |
| 1061 | if (!infoRef) { |
| 1062 | return undefined; |
| 1063 | } |
| 1064 | |
| 1065 | const info = this.ctx.registry.getObject(infoRef); |
| 1066 | |
| 1067 | if (!(info instanceof PdfDict)) { |
| 1068 | return undefined; |
| 1069 | } |
| 1070 | |
| 1071 | return info.getString("Title")?.asString(); |
| 1072 | } |
| 1073 | |
| 1074 | /** |
| 1075 | * Set the document title. |
no test coverage detected