Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCreationDate has issues parsing some dates #1545

Open
2 tasks done
saul-prepared opened this issue Nov 13, 2023 · 0 comments
Open
2 tasks done

getCreationDate has issues parsing some dates #1545

saul-prepared opened this issue Nov 13, 2023 · 0 comments

Comments

@saul-prepared
Copy link

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

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant