parallax/jsPDF · error · Error
Exception while creating AcroformDictionary
Error message
Exception while creating AcroformDictionary
What it means
Thrown by initializeAcroForm when it is asked to initialize the AcroForm plugin but scope.internal.acroformPlugin.acroFormDictionaryRoot already exists. This is a re-initialization guard: the dictionary root should be created exactly once. A second initialize attempt indicates duplicate init or corrupted plugin state.
Source
Thrown at src/modules/acroform.js:705
}
delete fieldArray[key];
}
}
};
var initializeAcroForm = function(scope, formObject) {
formObject.scope = scope;
if (
scope.internal !== undefined &&
(scope.internal.acroformPlugin === undefined ||
scope.internal.acroformPlugin.isInitialized === false)
) {
AcroFormField.FieldNum = 0;
scope.internal.acroformPlugin = JSON.parse(
JSON.stringify(acroformPluginTemplate)
);
if (scope.internal.acroformPlugin.acroFormDictionaryRoot) {
throw new Error("Exception while creating AcroformDictionary");
}
scaleFactor = scope.internal.scaleFactor;
// The Object Number of the AcroForm Dictionary
scope.internal.acroformPlugin.acroFormDictionaryRoot = new AcroFormDictionary();
scope.internal.acroformPlugin.acroFormDictionaryRoot.scope = scope;
// add Callback for creating the AcroForm Dictionary
scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID = scope.internal.events.subscribe(
"postPutResources",
function() {
AcroFormDictionaryCallback(scope);
}
);
scope.internal.events.subscribe("buildDocument", function() {
annotReferenceCallback(scope);
}); // buildDocument
View on GitHub (pinned to a3930ce03a)
Solutions
- Initialize AcroForm once per document and reuse the existing plugin state.
- Check isInitialized / acroFormDictionaryRoot before triggering initialization.
- Use a fresh jsPDF instance for each generated form document.
Example fix
// before (two code paths both add fields -> double init)
buildFormA(doc); buildFormB(doc); // second init throws
// after
if (!doc.internal.acroformPlugin || !doc.internal.acroformPlugin.acroFormDictionaryRoot) {
buildFormA(doc);
}
buildFormB(doc); // reuses existing plugin state Defensive patterns
Strategy: try-catch
Validate before calling
function acroFormNotInitialized(doc) {
var p = doc.internal && doc.internal.acroformPlugin;
return !p || !p.isInitialized || !p.acroFormDictionaryRoot;
}
// only trigger form building when not yet initialized Type guard
function isAcroFormInitialized(doc) {
return !!(doc.internal && doc.internal.acroformPlugin &&
doc.internal.acroformPlugin.acroFormDictionaryRoot);
} Try / catch
try {
initializeOrAddField(doc, field);
} catch (e) {
if (/Exception while creating AcroformDictionary/.test(e.message)) {
// already initialized; just add the field to existing plugin
doc.addField(field);
} else throw e;
} Prevention
- Initialize AcroForm once per document.
- Reuse the existing plugin state for additional fields.
- Use a fresh jsPDF instance per generated form document.
When it happens
Trigger: Adding AcroForm fields in a way that invokes initializeAcroForm twice (e.g. interleaving field creation with manual plugin manipulation), or a stale acroformPlugin object that retained a previous acroFormDictionaryRoot after a soft reset.
Common situations: Building forms across multiple code paths that both init forms; a jsPDF instance reused after an AcroForm build; a custom workflow that calls internal init directly.
Related errors
- putCatalogCallback: Root missing.
- 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
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/4323c25f89926818.
Report an issue: GitHub.