How do I read the format category information for a text field?

Adobe Acrobat allows a form author to specify various text field properties when creating a text field. In my form, I have a text field that accepts date values. In the Text Field Properties dialog box in Adobe Acrobat, I can specify that the format category is “Date”, and that the format string is


dd-mmm-yyyy HH:MM:ss tt

For example, 12 o’clock noon on Christmas Day, 2014:

25-Dec-2014 12:00:00 pm

The problem I’m running into is setting the field value using the Aspose PDF for .NET class library. If the PDF form field has an unusual format string like this, I need to be able to read that string so that I know how to format the date/time value when calling FillField():

// This won’t work with the format shown above:
form.FillField(“12/25/2014 12:00:00 pm”);

The application that I am building with your class library does not know ahead of time what the format string will be for the fields it works with–it needs to dynamically read this information from the PDF document that it is accessing.

So my question is: How do I retrieve the format category information embedded in the PDF document? I’ve looked and looked through the Aspose PDF documentation and have searched the various properties and methods exposed in the Visual Studio debugger at runtime, and it doesn’t look like this information is surfaced by your class library (or if it is, it’s not in an obvious place). Thanks.

Hi Scott,


Thanks for your inquiry. After initial investigation, we have logged an investigation ticket, PDFNEWNET-37099, for further investigation and resolution. We will keep you updated about the issue resolution progress via this forum thread.

Meanwhile, please share your sample PDF form containing fields with formatting. It would help us to investigate and address the issue.

We are sorry for the inconvenience caused.

Best Regards,

Document attached. If you look at the DATE_OF_EVENT field at the top of page 1 in Adobe Acrobat, you’ll see that it has a “Date” category and a custom date format string. But if you try to access this information via the Aspose PDF for .NET class library, the format information is not visible. Also, if you use


Aspose.Pdf.Facades.Form.FillField(id, value)

to change the field value, whatever you pass for value will be placed in the field–the formatting information embedded in the PDF document is ignored.

AHA! Found it.


// In the next statement, “form” is
// an instance of Aspose.Pdf.Facades.Form:
Aspose.Pdf.InteractiveFeatures.JavascriptAction theAction = (Aspose.Pdf.InteractiveFeatures.JavascriptAction)form.Document.Form[“DATE_OF_EVENT”].Actions.OnFormat;

If you examine the Script property of the JavascriptAction object, you’ll see it has this value:

AFDate_FormatEx(“dd-mmm-yyyy HH:MM:ss tt”);

Unfortunately, this doesn’t do me a lot of good. I don’t relish the thought of having to apply regular expression parsing to extract the format string that is a parameter to the AFDate_FormatEx() JavaScript function. It would be nice if the class library could dynamically extract the format string and make it available as a separate property.

I’m guessing that Adobe intended for the OnFormat action to only be used when the form is being interactively edited by a human being (rather than being modified by a third-party class library), but it still seems a shame to not be able to easily access this information. Now I will either have to tackle regex-ing the OnFormat property, or I’ll have to force my users to define their format strings twice (one in the PDF document itself, and once in some configuration file that’s readable by the application that’s using the Aspose class library).

Hi Scott,


Thank you very much sharing your source document and findings, we have shared these with our development team. Definitely, it will help us in the investigation and resolution. We will notify you as soon as this issue is resolved.

Best Regards,

The issues you have found earlier (filed as PDFNET-37099) have been fixed in Aspose.PDF for .NET 24.2.