• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Specifying file name when saving FDF file.

Participant ,
Jun 07, 2020 Jun 07, 2020

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.

TOPICS
Acrobat SDK and JavaScript

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jun 07, 2020 Jun 07, 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.

Votes

Translate

Translate
Community Expert , Jun 08, 2020 Jun 08, 2020

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.

Votes

Translate

Translate
Community Expert ,
Jun 07, 2020 Jun 07, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Thank you for your reply. I see. I give it up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

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"});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

Add a "/" to the start of the file path.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

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

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

What are the values of those two fields?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

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()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

You're using non-standard characters in your code. Your colon should be ":", not ":".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2020 Jun 08, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2020 Jun 07, 2020

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

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 08, 2020 Jun 08, 2020

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? 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

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

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines