These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Cant get formatted value to print with pdf...

barkerz10
Registered: Oct 6 2008
Posts: 5

Hi, I am trying to get a value formatted and to print with the pdf. I have this in the custom format section of the field:

if (event.value)
{
event.value = "XXX-XX-"+event.value.substr(5,4);
}

But on the pdf when I print all I get is 123456789 vs XXX-XX-6789. But it will show XXX-XX-6789 on the pdf until I click on it to edit it then it shows 123456789.

Not a clue as to what is going on.

Any help is good help.

Barkerz10

My Product Information:
Acrobat Pro 8.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Read this article about formatting

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/formatting_text_fields/

The format event does not change the value of the text field. It simply sets the appearance of the data. When you click on a text field, Acrobat puts the field into a kind of "edit" mode and exposes the underlying value of the field. Then you click off of a field, Acrobat commits the entered data into the real field value, which causes the data to be formatted before it is displayed.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

barkerz10
Registered: Oct 6 2008
Posts: 5
Thanks thomp for the quick response,
90% of the time this pdf will be populated dynamically, the formatting of that field is just one issue I was running into. That link was very helpful. But say a person doesn't type anything any after I format it the way I want it, how do I commit the changes to the event.value to the actual value of the field.

Thanks again,
Barkerz10

~ Any help is good help...
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It doesn't matter whether data is applied to the field interactively (from the user typing stuff in) or non-interactively (from data merging, calculation, or from a script). In all cases there is a data commit process that triggers three events: WillCommit, Validate, and Format. These events occur in order, with format being the last event.

The format event does not change the real value of the field. To do that you need to use one of the other event in the commit process. Validate is a good one. Use exactly the same script you were using in Format in the validate event. This will change the real value of the field.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script