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

Acroform Date field format not working #1546

Open
duhmojo opened this issue Aug 21, 2024 · 1 comment
Open

Acroform Date field format not working #1546

duhmojo opened this issue Aug 21, 2024 · 1 comment

Comments

@duhmojo
Copy link

duhmojo commented Aug 21, 2024

Bug Report

Description of the problem

Just trying to create a form with a date field. Setting a formText() format doesn't seem to do much. In Chrome and MacOS Preview the date field doesn't support or isn't prompted to show the date picker, and the format param isn't honoured. In Acrobat Reader there's a drop down date picker, but picking a date doesn't set the field value to display using the param format. Changing the year in the date picker doesn't show the date either. So I can have 2 dates from 2024 and 2023 and they're not displaying correctly.

image

doc.fontSize(10).formText(field.name, xOffset, lOffset, fieldWidth - 10, lfieldHeight, {
    format: { type: 'date', param: 'yyyy-mm-dd' },
})

I'm not sure if I'm doing something wrong or what to expect. The docs don't set much in the way of expectations.

The pdfkit docs (https://pdfkit.org/docs/forms.html#text_field_formatting) Acrobat SDK link is broken as well:

"When needing to format the text value of a Form Annotation, the following options are available. This will cause predefined document JavaScript actions to automatically format the text. Refer to the section Formatting scripts in Acrobat Forms Plugin of the Acrobat SDK documentation for more information."

Code sample

I wasted enough time with repl.it accessing my GitHub account and it doesn't build a pdf correctly. Try this:

const Document = require('pdfkit')
const fs = require('fs');

const doc = new Document();

doc.pipe(fs.createWriteStream('output.pdf'));

doc.initForm();
doc.fontSize(10).formText("date", 100, 100, 100, 25, {
    format: { type: 'date', param: 'yyyy-mm-dd' }
})

doc.end();

Your environment

  • pdfkit version: 0.13.0
  • Node version: 20.12.1
  • Browser version (if applicable): Chrome (Linux), Chrome (Mac), Preview (Mac), Acrobat DC Reader 2022.002.20212
  • Operating System: Linux, macOS
@duhmojo
Copy link
Author

duhmojo commented Sep 22, 2024

Nobody? Is this the extent of what PDF offers for date fields? Is there another correct date field or usage that'll unlock something similar to what typical browser offer?

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

No branches or pull requests

1 participant