How do I apply form field formatting defined using Acrobat?

Q; Can you please tell me if your PDFNet SDK product supports applying
formatting defined on a field using Acrobat, when you populate the
form in
an application using the sdk? In other words, when you build the form
Acrobat, you can set up formatting on a fields, such as rounding to 2
decimal, date formatting etc. When my application fills the form
using your
sdk, then flattens it, will it have the formatting?
A: Unfortunately PDF specification itself does not specify these
formatting properties (such as rounding to 2 decimal, date formatting
etc). Acrobat supports these properties by associating a custom
JavaScript snippets with form fields. At the moment PDFNet SDK does
not include a JavaScript engine, so the fields will not be formatted
accordingly (this will probably change in the near future). In the
meantime, you could always format the numbers and other fields (e.g.
using .NET sting and formatting) before passing the
string values to PDFNet (as shown in InteractiveForms sample -

Q: That idea had occurred to me, but I want to be able to empower the
user who is building the forms to be able to set the formatting, and
as far as I can tell, there is no way for me to 'read' what has been
set so that I can apply the correct formatting.
A: You can use PDFNet to extract JavaScript command and apply
appropriate formatting. The following code snippet extracts the
embedded JavaScript:

Field f = ...

// Get additional-actions dictionary defining the field’s behavior //
in response to various trigger events Obj aa = f.GetSDFObj().FindObj
("AA") if (aa != null) {
  // Get JavaScript action to be performed before the field is
  // formatted to display its current value. This action can
  // modify the field’s value before formatting.
  Obj fmt = aa.FindObj("F");
  if (fmt != null) {
    // extract embedded JavaScript...
    Obj stm = fmt.GetDecodedStream();
    FilterReader reader = new FilterReader(stm);
    reader.Read(...extract JS ....);

The extracted JavaScript string would look as follows:

AFNumber_Format(6, 1, 1, 0, "\u0024", true);

This line can be easily recognized (using AFNumber_Format) and parsed.
In this case the command sets the field format to a decimal number
with 6 decimal places, no separator, and dollar ($) as a currency
symbol. Please see Acrobat JavaScript Reference Manual for detailed
documentation on other formatting commands.