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

Delete files

LMPIPER
Registered: Apr 4 2007
Posts: 16

We do what we call Auto Fills. They are pdf docs that populate some fields from dat files a Marco has created on the user’s hard drives. When the pdf doc is accessed its Javascript uses these dat files to get the needed data, (see script below).
  
this.getField("IV5").value = (d.getMonth()+1).toString()+"/"+d.getDate().toString()+"/"+d.getFullYear();
 
DataPath = "C:\\ueid.dat";
importTextData(DataPath,0);
var Ueid = this.getField("ueid");
var Ueidv = Ueid.value;
DataPath = "D:\\users\\"+Ueidv+"\\DBU data\\fd792.dat";
importTextData(DataPath,0);
DataPath = "C:\\Documents and Settings\\"+Ueidv+"\\SBU\\ename.dat";
importTextData(DataPath,0);
DataPath = "C:\\Documents and Settings\\"+Ueidv+"\\SBU\\epnum.dat";
importTextData(DataPath,0);
  
All of this works fine but I would like to also delete the fd792.dat file just after using it. Unfortunately I can not find any code that works to do this file delete. Can this be done and if so can you post the code needed?

My Product Information:
Acrobat Pro 6.0.5, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Acrobat JavaScript is built around a "SandBox" philosophy. This is supposed to make Acrobat a secure programing environment, i.e. no one can use Acrobat/PDF for malicous purposes. Everything you need is inside the sandbox and Acrobat only offers limited, and very restricted access to the outside world.

Deleting a file from the user's hard drive is right off the map. As useful as this could be (and I've wished for it quite often), you will never be able to do it. In fact, your code is going to break in Acrobat 8 because they've added more restrictions for accessing outside data. Take a look at the latest JS Ref.

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