Trying to get the creation date of a PDF. The PDF has a creation date of D:20210514143134-5'00'
How did you attempt to do it?
Call the getCreationDate function.
const data = new Uint8Array(doc.Body as Buffer);const pdfDoc = await PDFDocument.load(data, {updateMetadata: false})let originalCreateDate = moment(pdfDoc.getCreationDate()).utc().toDate();
What actually happened?
It throws the following error "Attempted to convert "D:20210514143134-5'00'" to a date, but it does not match the PDF date string format."
What did you expect to happen?
Expected it to return a date.
How can we reproduce the issue?
Here is the link to the JS fiddle https://jsfiddle.net/3fu4vj2c/1/
The example is the copied and pasted parseDate function.
I cannot provide the pdf file that caused the issue because it is a legal document that cannot be shared.
The JS Fiddle has a suggested fix as well.
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
[X] My report includes a Short, Self Contained, Correct (Compilable) Example.
[X] I have attached all PDFs, images, and other files needed to run my SSCCE.
What were you trying to do?
Trying to get the creation date of a PDF. The PDF has a creation date of D:20210514143134-5'00'
How did you attempt to do it?
Call the getCreationDate function.
const data = new Uint8Array(doc.Body as Buffer);
const pdfDoc = await PDFDocument.load(data, {
updateMetadata: false
})
let originalCreateDate = moment(pdfDoc.getCreationDate()).utc().toDate();
What actually happened?
It throws the following error "Attempted to convert "D:20210514143134-5'00'" to a date, but it does not match the PDF date string format."
What did you expect to happen?
Expected it to return a date.
How can we reproduce the issue?
Here is the link to the JS fiddle https://jsfiddle.net/3fu4vj2c/1/ The example is the copied and pasted parseDate function. I cannot provide the pdf file that caused the issue because it is a legal document that cannot be shared.
The JS Fiddle has a suggested fix as well.
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response