-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Bug Report
Description of the problem
When using acroforms, setting a boolean option to false
will still add the flag to the PDF document.
This is caused by the function resolveFlags(options)
in lib/mixins/acroforms.js
not checking the value of the options - as long as a corresponding key is set to any value (even undefined
), their flag is added to the field.
Example:
The option password
is explicitly set to false
, but the form text gets rendered with the password flag (only asterisks shown).
(Screenshot uses the code sample from below.)
I am currently creating a pull request, which will fix this issue.
PR #1496 is ready.
Code sample
I forked the repo and modified the example in the webpack folder:
var doc = new PDFDocument();
doc.registerFont('Roboto', 'fonts/Roboto-Regular.ttf');
doc.initForm();
var opts = {
value: "sample",
password: false
};
doc.formText("example", 100, 100, 200, 40, opts);
// waitForData must be called before call to doc.end()
waitForData(doc)
.then(dataUrl => {
// display the document in the iframe to the right
iframe.src = dataUrl;
})
.catch(error => {
console.log(error);
});
doc.end();
Your environment
- pdfkit version:
0.14.0
(forked frommaster
) - Node version:
v20.11.0
- Browser version (if applicable): Chrome
121.0.6167.139
(arm64) - Operating System: macOS Sonoma 14.3 (M1)
Metadata
Metadata
Assignees
Labels
No labels