Skip to main content
Inspiring
June 7, 2020
Answered

Specifying file name when saving FDF file.

  • June 7, 2020
  • 2 replies
  • 3626 views

I don't know why, but the question I wrote earlier has been treated as spam. I will shorten the question text and post it again.

 

When saving with FDF, I want to save with a file name that is a concatenation of some field names in the form and the save date and time. First, I tried writing the following code in a text field. The file name as expected is displayed.

 

 

var Pink = this.getField("PINK");
var Blue = this.getField("BLUE");
var FNAME = util.printd("yyyymmdd-HHMM-",new Date())+Pink.value+"-"+Blue.value+".fdf";
event.value = FNAME;

 

 

And then I created a button and created the following code. I deleted the last line above and added the following. I don't want to be treated as spam again, so I'll just list only one.  I'm actually trying out more code. But those was all a failure. Because I want to let the user choose where to save the file, the save window must be opened. 

 

 

this.exportAsFDF({cPath:cPath + FNAME});

 

 

Actually I tried the following too.

 

 

this.exportAsFDF(util.printd("yyyymmdd-HHMM-",new Date())+Pink.value+"-"+Blue.value+".fdf")

 

 

Please tell me the correct description method. I haven't been able to find the right material for me.

Correct answer try67

Oh Sorry..I have corrected your issue.

this.exportAsFDF({cPath: "/C/FDFSAVE/AA.fdf"});

The result returned to the first error display.

RangeError: The argument value is invalid.
Doc.exportAsFDF:3:AcroForm:PINK_FDF:Annot1:MouseUp:Action1

 


We already answered that question before. You can't specify the file-path from the MouseUp event directly. You have to run it from a trusted context to be able to do that.

2 replies

Thom Parker
Community Expert
June 7, 2020
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
June 8, 2020

Thank you very much. I noticed this reply earlier. I have read it briefly, does this content affect saving in FDF format? 

 

 

Thom Parker
Community Expert
June 8, 2020

Yes, any operation that writes to the local file system is restricted.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
June 7, 2020

This is not possible. You can either specify the full file path (including folder) or let the user select where to save the file and how to name it. You can't let them select a folder and then decide what file name to use.

Inspiring
June 8, 2020

Sorry.. Please help me. Actually I'm still in bothere. I have no clue what's wrong with the code below. I created a new folder directly under the c drive.

this.exportAsFDF({cPath: "C/FDFSAVE/"+util.printd("yyyymmdd-HHMM-",new Date())+Pink.value+"-"+Blue.value+".fdf"});
try67
try67Correct answer
Community Expert
June 8, 2020

Oh Sorry..I have corrected your issue.

this.exportAsFDF({cPath: "/C/FDFSAVE/AA.fdf"});

The result returned to the first error display.

RangeError: The argument value is invalid.
Doc.exportAsFDF:3:AcroForm:PINK_FDF:Annot1:MouseUp:Action1

 


We already answered that question before. You can't specify the file-path from the MouseUp event directly. You have to run it from a trusted context to be able to do that.