We do what we call Auto Fills. They are pdfs that self populate some data from dat files stored on the user’s hard disk. My users have adobe versions 5 thru 7. Some of them are about to get 8. The current JavaScript code will not work at 8. I have updated the code, (see below) adding an Adobe 8 section. The new code uses a Folder level script, (Importdata.js). The new code works fine for Adobe versions 5 thru 8 as long as the pdf doc is accessed from the user’s hard drive or a shared drive.
The problem is that our users access these pdfs from an intranet web page, and they do not work with adobe 8. If I copy a web pdf to my desktop it auto fills just as it should. It is acting like it is not able to access the folder level script. I have placed this script in both the local and global locations.
What am I missing?
Folder Level Importdata.js
TrustedImportTextData = app.trustedFunction( function ( oDoc, z, w )
{
app.beginPriv();
var myReturn = oDoc.importTextData(z,w)
app.endPriv();
return myReturn;
});
Document Level Script
/*********** belongs to: Document-Level:SelectVersion ***********/
function SelectVersion()
{
if (typeof app.formsVersion != "undefined" && app.formsVersion >= 8)
importData()
else
StartMe()
}
//
//
//
//StartMe
//
/*********** belongs to: Document-Level:StartMe ***********/
function StartMe()
{
DataPath = "C:\\seid.dat";
importTextData(DataPath,0);
var Seid = this.getField("seid");
var Seidv = Seid.value;
DataPath = "D:\\users\\"+Seidv+"\\SBU data\\Form9856.dat";
importTextData(DataPath,0);
var DataPath ;
DataPath = "C:\\Documents and Settings\\"+Seidv+"\\SBU\\Stop.dat";
importTextData(DataPath, 0);
DataPath = "C:\\Documents and Settings\\"+Seidv+"\\SBU\\IDRSnumber.dat";
importTextData(DataPath, 0);
var d = new Date();
this.getField("date").value = (d.getMonth()+1).toString()+"/"+d.getDate().toString()+"/"+d.getFullYear();
}
//
//
//
//importData
//
/*********** belongs to: Document-Level:importData ***********/
function importData()
{
TrustedImportTextData(this,"/c/seid.dat",0);
var Seid = this.getField("seid");
var Seidv = Seid.value;
TrustedImportTextData(this,"D:/users/"+Seidv+"/SBU data/Form9856.dat",0);
TrustedImportTextData(this,"C:/Documents and Settings/"+Seidv+"/SBU/Stop.dat",0);
TrustedImportTextData(this,"C:/Documents and Settings/"+Seidv+"/SBU/IDRSnumber.dat",0);
var d = new Date();
this.getField("date").value = (d.getMonth()+1).toString()+"/"+d.getDate().toString()+"/"+d.getFullYear();
}
//
//
//
//Page1:Page Open:Action2
//
/*********** belongs to: Page-Actions:Page1:Page Open:Action2 ***********/
SelectVersion();
//
//
Thanks for your help.
Leo
When you say that the form was accessed from the Web, do you mean that the PDF was displayed in the browser?
If you force the PDF to not be displayed in the browser what happens? In the Acrobat Preferences, open the "Internet" panel and unselect "Display PDF in browser".
Acrobat 8 has more security features than earlier versions and importing data from a local file is a potential security hazard. Also, Acrobat has always acted differently when it is displayed in an external window. It's very likely that Acrobat just bumped up the restrictions on this kind of usage.
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