* Get the document creation date. * * @returns The creation date, or undefined if not set or invalid
()
| 1284 | * @returns The creation date, or undefined if not set or invalid |
| 1285 | */ |
| 1286 | getCreationDate(): Date | undefined { |
| 1287 | const infoRef = this.ctx.info.trailer.getRef("Info"); |
| 1288 | |
| 1289 | if (!infoRef) { |
| 1290 | return undefined; |
| 1291 | } |
| 1292 | |
| 1293 | const info = this.ctx.registry.getObject(infoRef); |
| 1294 | |
| 1295 | if (!(info instanceof PdfDict)) { |
| 1296 | return undefined; |
| 1297 | } |
| 1298 | |
| 1299 | const dateStr = info.getString("CreationDate")?.asString(); |
| 1300 | |
| 1301 | if (!dateStr) { |
| 1302 | return undefined; |
| 1303 | } |
| 1304 | |
| 1305 | return parsePdfDate(dateStr); |
| 1306 | } |
| 1307 | |
| 1308 | /** |
| 1309 | * Set the document creation date. |
no test coverage detected