Fix LiveCycle saveAs JavaScript Error vDoc Is Undefined in PDF
Question details
The user needs to fix a TypeError stating 'vDoc is undefined' when executing a folder-level trusted saveAs script from a LiveCycle XFA form.

- Product
- Adobe LiveCycle XFA Forms
- Device & OS
- not provided
- Scenario
- Triggering a custom saveAs JavaScript function to save a PDF form dynamically.
- Observed behavior
- The script execution halts and returns a 'TypeError: vDoc is undefined' message due to an incorrect document object reference and a parameter mismatch.
Ensure you have access to your folder-level JavaScript (.js) files on your local system and check that your PDF editor's JavaScript execution settings are fully enabled.
Pass the Correct Acrobat Document Object
Replace the XFA form node reference with the Acrobat document object so the script can correctly identify the PDF file it needs to save.
In XFA forms, the saveAs syntax requires the main Acrobat document object. Using a form-specific node reference like 'resolveNode.topmostSubForm' fails because it points to the form's XML structure rather than the document itself.
Launch Adobe LiveCycle Designer and navigate to the script editor for the specific button or event triggering the saveAs function.
Find the line of code where your folder-level trusted saveAs function is called (e.g., myTrustedSaveAs(resolveNode.topmostSubForm)).
Change 'resolveNode.topmostSubForm' to 'this'. The keyword 'this' correctly references the parent Acrobat document object required by the API.
Save the form, open it in Acrobat, and trigger the script to ensure the PDF saves without throwing the vDoc error.

Correct the Function Parameter Mismatch
Adjust the number of arguments in your function call to match exactly what your folder-level JavaScript function definition expects.
Create and Manage Standard PDF Forms with WPS Office
If you want to avoid the complexities of deprecated XFA forms and folder-level JavaScript errors, you can use WPS Office to create, manage, and interact with standard PDF forms effortlessly.
- 1. Open WPS PDF: Launch WPS Office and click on the 'PDF' tab on the home screen.
- 2. Load your PDF Form: Click 'Open' and select your standard PDF form from your local directory.
- 3. Fill and Save: Use the integrated form tools to fill out the document, then simply click 'Menu' > 'Save As' to store a copy locally without needing custom JavaScript.

Frequently Asked Questions
What is the difference between 'this' and 'resolveNode' in PDF JavaScript?
In the context of a PDF, 'this' generally refers to the Acrobat document object itself, which handles file-level operations like saving and printing. 'resolveNode' is specific to XFA forms and targets elements within the form's internal XML hierarchy.
Why does my trusted saveAs script require folder-level access?
For security reasons, PDF readers restrict scripts from saving files silently to a user's hard drive. The saveAs API must be executed within a 'trusted' context, which involves placing a specific JavaScript file in a designated protected folder on the local machine.
Are LiveCycle XFA forms still widely supported?
Dynamic XFA forms are considered a legacy Adobe technology. They are largely unsupported by modern web browsers, mobile devices, and most third-party PDF editors, which prefer standard interactive PDFs (AcroForms).




