PDF Editing Issues

How to Format Currency as French Canadian Dollars in Acrobat JavaScript

Rana GarciaRana Garcia Nov 5, 2026 869 views

Question details

The user needs to format a PDF currency field to display numeric values in the French Canadian style (e.g., 1 234,56 $) using JavaScript, while avoiding NaN errors caused by mixed separators.

How to Format Currency as French Canadian Dollars in Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Developing interactive PDF forms that require specific regional currency formatting and robust input validation for French Canadian users.
Observed behavior
When users input numbers containing both decimal and thousands separators, the field produces NaN (Not a Number) errors unless the format is explicitly defined or restricted via scripting.
Before you start

Ensure you have access to the 'Prepare Form' tools in your PDF editor and possess a basic understanding of adding custom JavaScript to form field properties.

Solution 1Recommended

Use Custom Format and Keystroke Scripts

Apply a custom JavaScript formatting script to arrange separators correctly, append the dollar sign, and use a keystroke script to prevent invalid characters like spaces.

Acrobat's built-in formatting may not natively support the exact French Canadian layout by default. By combining a formatting script to arrange the output and a keystroke script to sanitize the input, you ensure clean data collection.

1
Access Field Properties

Open your PDF in 'Prepare Form' mode. Right-click the target text field and select 'Properties', then navigate to the 'Format' tab.

2
Apply Custom Format Script

Select 'Custom' from the format category drop-down. In the Custom Format Script box, enter: event.value = util.printf("%,2.2f $", event.value).toString().replace(/\./gim, " "); to format the output with a dollar sign.

3
Add a Keystroke Script

Switch to the Custom Keystroke Script box and add code to block manual spaces: if (event.change == " ") { event.change = ""; }. This prevents users from breaking the numeric input with spacebars.

Use Custom Format and Keystroke Scripts
Adapting Currency Symbols: If you are formatting for European French users, you can easily replace the '$' with the '€' symbol in the util.printf statement.
Free Microsoft Office alternative

Manage PDF Forms Easily with WPS Office

While Acrobat JavaScript provides deep customization, building and managing complex PDF forms can be daunting. WPS Office offers a highly compatible, free alternative with intuitive PDF viewing, editing, and form-filling capabilities. Enjoy seamless standard PDF compatibility and a familiar, user-friendly interface.

Free and lightweight PDF editing and form-filling toolsFully compatible with standard PDF forms and Microsoft Office formatsFamiliar, user-friendly interface requiring no advanced scripting skillsSeamless transition and document handling across multiple devices
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF currency field show NaN?

NaN (Not a Number) occurs when the PDF engine attempts a calculation on a string it cannot parse as a valid number. This typically happens when users input unexpected formatting characters, such as multiple commas or spaces, without strict validation.

How do I stop users from typing spaces in a PDF text field?

You can block spaces by using a Custom Keystroke Script in your form field properties. Entering 'if (event.change == " ") { event.change = ""; }' will actively reject any spacebar inputs.

What does util.printf do in Acrobat JavaScript?

The util.printf method is an Acrobat-specific function used to format numbers and strings. For example, using '%,2.2f' tells the application to format the input as a floating-point number with two decimal places and thousands separators.

Can I edit PDF forms using WPS Office?

Yes, WPS Office includes a built-in PDF toolset that allows you to open, fill out, and manage standard interactive PDF forms with high compatibility and performance.