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

JavaScript doesn't run on acrobat reader 8 (Continuation)

whatever
Registered: Aug 23 2007
Posts: 21

This message is related to the one posted today.
 
I'm attaching the script again at the end, altough i've already found the line where acrobat reader fails:
 
this.removeField(fieldName);
 
So, now i'm wonder how to solve this method call.
 
Thanks Thom, i could find the exact line by doing some debugging!!.
 
/* In the following script i've changed the less than symbol for < literal in order to have it well displayed */
var feimp=new Date();
var lorva='VALIDO POR EL DIA DE '+util.printd("dd/mmm/yyyy HH:MM:ss",feimp)+'.';
for(var pag=0;pag < this.numPages;pag++){
var fieldName='txtBtm'+pag;
var mife=this.getField(fieldName);
if(mife!=null) this.removeField(fieldName);
var aRect = this.getPageBox( {nPage: pag} );
var bRect=Array(0,aRect[1],60,0);
mife=this.addField(fieldName,'text',pag,bRect);
mife.display=display.noView;
mife.alignment='center';
mife.textFont=font.TimesB;
mife.textSize=18;
mife.rotation=90+this.getPageRotation(pag);
mife.value=lorva;
}
this.dirty=false;

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This code will only run on Acrobat Reader 8 if it is Reader Enbled with Form Rights. Field creation and deletion is not normally allowed in Reader. Look up the functions you are using in the Acrobat JavaScript Reference to check for restrictions before using any JavaScript function or property.

The above script can be used as an automation script for setting up your PDFs in Acrobat Pro. Place it in a Folder Level Script and use a toolbar button or menu item to run the code.

However, you have way too much code here anyway. You should not be doing field creation on a working form. The fields should already exist on the doc that distributed to users. All you need to do is fill in the date value. There is also no need to put different fields on each page. Name all the field same and you only have to fill it in once.

Put this one line of code in your "WillPrint" event

this.getField("txtBtm").value = 'VALIDO POR EL DIA DE '+util.printd("dd/mmm/yyyyHH:MM:ss",new Date())+'.';

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

whatever
Registered: Aug 23 2007
Posts: 21
Thom, thank you very much!!

I made what you said and it works fine now.

Thanks for your time in both explaining and solving this issue. I ought you many.

Rafael