Copy link to clipboard
Copied
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.
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you for your reply. I see. I give it up.
Copy link to clipboard
Copied
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"});
Copy link to clipboard
Copied
Add a "/" to the start of the file path.
Copy link to clipboard
Copied
I had try it.
this.exportAsFDF({cPath: "/C/FDFSAVE/"+util.printd("yyyymmdd-HHMM-",new Date())+Pink.value+"-"+Blue.value+".fdf"});
But it say,
RangeError: The argument value is invalid.
Doc.exportAsFDF:3:AcroForm:PINK_FDF:Annot1:MouseUp:Action1
Copy link to clipboard
Copied
What are the values of those two fields?
Copy link to clipboard
Copied
Both are text.
I tried the following to investigate the cause.
this.exportAsFDF({cPath:"/C/FDFSAVE/AA.fdf"});
Then the following appeared.
SyntaxError: missing : after property id
I have no idea what is happening. Only the following works properly.
this.exportAsFDF()
Copy link to clipboard
Copied
You're using non-standard characters in your code. Your colon should be ":", not ":".
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you very much. I'm not an expert yet, so I sometimes confuse the meaning of the advice. Please forgive me. I do not know the meaning of trusted context. I will check it up.
Copy link to clipboard
Copied
Eventually I reached my goal in another way. I will report how. Thank you very much. It's definitely thanks to you that I got to this code. I still don't understand all what acrobats can or cannot do.
var Pink = this.getField("PINK");
var Blue = this.getField("BLUE");
var FDFNAME = util.printd("yyyymmdd-HHMM-",new Date())+Pink.value+"-"+Blue.value+".fdf";
PINKFDF = app.response("Copy and use below as the save name of the FDF.","",FDFNAME);
app.alert(PINKFDF);
this.exportAsFDF()
Thank you for your continued support.
Copy link to clipboard
Copied
Read these articles, they explain you current code won't work and how to make it work.
https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm?sd=40
https://www.pdfscripting.com/public/How-to-Save-a-PDF-2.cfm
Copy link to clipboard
Copied
Thank you very much. I noticed this reply earlier. I have read it briefly, does this content affect saving in FDF format?
Copy link to clipboard
Copied
Yes, any operation that writes to the local file system is restricted.