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

Forms

lfernandes
Registered: Aug 1 2007
Posts: 4

I have created a PDF template using Acrobat7.0 Professional with form fields which are populated through xml tags.
I need to write a conditional statement based on the page number for a form field.
I tried using this.pageNum and this.numPages but I can't get it to work.This is what I am trying to do
eg:
 
var TotalPages = this.numPages;
var CurrentPage = this.pageNum;
var c_field1= this.getField("FIELD1");
var c_field2 = this.getField("FIELD2");
 
if (this.CurrentPage == this.TotalPages) {
event.value = c_field1;
} else {
event.value = c_field2;
}
 
Ive written this script on a form field in the template.However the document runs into many pages.Dependding on the current page(If it is not the last) I need to display a value for the formfield.
Would appreciate if you could help me out.

My Product Information:
Acrobat Pro 7.0.9, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
They way you have your code written the variables "c_field1" and "c_field2" are field objects. To get the field value from these field objects you have to use the "value" property, like this:

event.value = c_field1.value;

Of course this only works for AcroForms. It will not work for an XFA form (i.e. built with LiveCycle Designer)

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

lfernandes
Registered: Aug 1 2007
Posts: 4
Thanks for your response...
The template is an AcroForm.
It is used by XML Publisher to create a pdf output with xml data generated from a report.I need to confirm if I am deriving the correct values for the total page number.

What can I do on the the pdf template to display the total no.of pages on the output(which contains multiple pages)?
Will this need a document level script?or Can I do it using just a formfield.?
Thanks