Fix event.source is null Error in PDF Dynamic Stamp Scripts
Question details
The user is encountering a script error when testing a custom dynamic stamp in a PDF editor.

- Product
- Adobe Acrobat / PDF
- Device & OS
- not provided
- Scenario
- Testing a JavaScript dynamic stamp
- Observed behavior
- The system returns a "TypeError: event.source is null" message instead of executing the stamp script.
Before troubleshooting, ensure you have your JavaScript debugging console enabled in your PDF editor to monitor execution logs and syntax errors.
Apply the File as a Stamp Instead of Opening It
The error typically occurs because the stamp file is opened as a standard PDF document rather than being deployed as an actual stamp.
When a stamp file is opened directly in a PDF reader like Acrobat, the `event.source` object does not exist because no stamping action is taking place. This causes the script to evaluate the source as null, leading directly to the TypeError.
To resolve this, you must test the script by applying the stamp to another active document.
Open a standard PDF document (not your development stamp file) in your PDF editor.
Navigate to the Comment or Stamp tool menu and locate your custom dynamic stamp from the library.
Click anywhere on the open document to apply the stamp. The script should now recognize the `event.source` context and execute correctly.

Correct JavaScript Capitalization and Syntax
JavaScript is highly case-sensitive. Using incorrect capitalization for utility functions can trigger secondary errors that disrupt your stamp script.
Easily Add Custom Stamps to PDFs with WPS Office
If complex JavaScript syntax and scripting errors are slowing down your workflow, WPS Office offers a straightforward way to add custom stamps to your PDF documents without writing any code.
- 1. Open the PDF File: Launch WPS Office and open the PDF document you want to stamp.
- 2. Navigate to the Comment Tab: Click on the 'Comment' tab located on the top navigation ribbon.
- 3. Access the Stamp Library: Click the 'Stamp' icon to view the built-in library of professional stamps.
- 4. Add a Custom Stamp: Select 'Custom Stamp' from the dropdown menu to upload your own image or personalized signature.
- 5. Place the Stamp: Click anywhere on your document page to place the stamp perfectly.

Frequently Asked Questions
Why does my JavaScript work in the console but fail in the dynamic stamp?
Scripts run directly in the console have a different execution context. Dynamic stamps rely on specific event triggers, like `event.source`, that are only generated when the stamp is actively placed onto a target document.
How do I open the JavaScript debugger in Acrobat to check for stamp errors?
You can quickly open the JavaScript debugger by pressing Ctrl+J on Windows or Cmd+J on a Mac. This allows you to monitor real-time execution errors, such as syntax mistakes or null reference issues.
Can I create a dynamic PDF stamp without using JavaScript?
Basic image stamps and static text stamps do not require JavaScript. However, if you want dynamic elements (like auto-generating the current date or username), scripting is usually required in traditional editors. You can use modern alternatives like WPS Office to insert standard custom stamps effortlessly without coding.




