parallax/jsPDF · error · Error
Invalid arguments passed to jsPDF.API.__acroform__.clearBitF
Error message
Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf
What it means
Thrown by clearBitForPdf(number, bitPosition) when either argument is NaN. This is the 1-based wrapper over clearBit (delegates with bitPosition-1) used by AcroForm boolean setters to turn a PDF flag bit off. Exposed at jsPDF.API.__acroform__.clearBitForPdf.
Source
Thrown at src/modules/acroform.js:152
var setBitForPdf = (jsPDFAPI.__acroform__.setBitForPdf = function(
number,
bitPosition
) {
if (isNaN(number) || isNaN(bitPosition)) {
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf"
);
}
return setBit(number, bitPosition - 1);
});
var clearBitForPdf = (jsPDFAPI.__acroform__.clearBitForPdf = function(
number,
bitPosition
) {
if (isNaN(number) || isNaN(bitPosition)) {
throw new Error(
"Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf"
);
}
return clearBit(number, bitPosition - 1);
});
var calculateCoordinates = (jsPDFAPI.__acroform__.calculateCoordinates = function(
args,
scope
) {
var getHorizontalCoordinate = scope.internal.getHorizontalCoordinate;
var getVerticalCoordinate = scope.internal.getVerticalCoordinate;
var x = args[0];
var y = args[1];
var w = args[2];
var h = args[3];
var coordinates = {};View on GitHub (pinned to a3930ce03a)
Solutions
- Validate number and bitPosition are finite numbers (bitPosition >= 1) before calling clearBitForPdf.
- Keep F/Ff numeric at all times so boolean setters can clear bits safely.
- Reset corrupt flag fields to their defaults (F=4, Ff=0) before toggling properties.
Example fix
// before field.showWhenPrinted = false; // _F is NaN -> clearBitForPdf throws // after if (typeof field.F !== 'number' || isNaN(field.F)) field.F = 4; field.showWhenPrinted = false;
Defensive patterns
Strategy: type-guard
Validate before calling
function safeClearBitForPdf(number, bitPosition) {
number = Number(number);
var p = Number(bitPosition);
if (!isFinite(number) || !isFinite(p) || p < 1) {
throw new Error('clearBitForPdf needs finite number and bitPosition>=1');
}
return jsPDF.API.__acroform__.clearBitForPdf(number, p);
} Type guard
function areFiniteNumbers(a, b) {
return typeof a === 'number' && isFinite(a) &&
typeof b === 'number' && isFinite(b) && b >= 1;
} Try / catch
try {
field.F = jsPDF.API.__acroform__.clearBitForPdf(field.F, pos);
} catch (e) {
if (/__acroform__.clearBitForPdf/.test(e.message)) {
if (typeof field.F !== 'number' || isNaN(field.F)) field.F = 4;
field.F = jsPDF.API.__acroform__.clearBitForPdf(field.F, pos);
} else throw e;
} Prevention
- Keep F/Ff numeric; reset corrupt flags to defaults (F=4, Ff=0).
- Pass only finite, 1-based positions to clearBitForPdf.
- Prefer boolean property setters over manual bit clearing.
When it happens
Trigger: Calling clearBitForPdf with NaN, or toggling an AcroForm boolean property to false when the underlying _F/_Ff flag is NaN, or passing an undefined PDF bit position.
Common situations: Setting field.showWhenPrinted = false (or other boolean props) after _F became NaN; clearing flags with a position read from missing config.
Related errors
- Invalid arguments passed to jsPDF.API.__acroform__.setBit
- Invalid arguments passed to jsPDF.API.__acroform__.clearBit
- Invalid arguments passed to jsPDF.API.__acroform__.getBit
- Invalid arguments passed to jsPDF.API.__acroform__.getBitFor
- Invalid arguments passed to jsPDF.API.__acroform__.setBitFor
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/110b1c27de60cb4c.
Report an issue: GitHub.