You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
My report includes a Short, Self Contained, Correct (Compilable) Example.
I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
No response
The text was updated successfully, but these errors were encountered:
/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+-Z])?(\d?\d)?'?(\d\d)?'?'?$/
solves the issue, but your date is not a valid JS Date, so maybe you should modify the function too, to add automatically a 0 if none was provided.
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
The text was updated successfully, but these errors were encountered: