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
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:
vardoc=newPDFDocument();doc.registerFont('Roboto','fonts/Roboto-Regular.ttf');doc.initForm();varopts={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 rightiframe.src=dataUrl;}).catch(error=>{console.log(error);});doc.end();
Your environment
pdfkit version: 0.14.0(forked from master)
Node version: v20.11.0
Browser version (if applicable): Chrome 121.0.6167.139 (arm64)
Operating System: macOS Sonoma 14.3 (M1)
The text was updated successfully, but these errors were encountered:
RicoBrase
added a commit
to RicoBrase/pdfkit
that referenced
this issue
Feb 4, 2024
…1496)
* Add an option check to acroform mixin _resolveFlags().
This resolves#1495.
* Reworked fix to remove flags from options, if they are falsey.
* Added unit test for ignoring false flags in acroforms
* Added entry for removing false flags in changelog.
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)
inlib/mixins/acroforms.js
not checking the value of the options - as long as a corresponding key is set to any value (evenundefined
), their flag is added to the field.Example:
The option
password
is explicitly set tofalse
, 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:
Your environment
0.14.0
(forked frommaster
)v20.11.0
121.0.6167.139
(arm64)The text was updated successfully, but these errors were encountered: