Save FDF as a silently and using name from Acrobat form field.

Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Dear All;
I would like to save the donation receipt information as a FDF, which is I already created through Acrobat Pro DC version 2019.008.20080 fillable form.

Again, through the code I found on this forum site, I can save the PDF form as a complete. But I want to save as a FDF, how to change the JavaScript code for this purpose?

Thanks in advance for your help

Code:@ !

I used the script below in my Javascript folder:

var mySaveAs = app.trustedFunction(

  function(oDoc, cPath, cFlName) {

  // Ensure path has trailing "/"

  cPath = cPath.replace(/([^/])$/, "$1/");

  try {

  app.beginPriv();

  oDoc.saveAs(cPath + cFlName);

  app.endPriv();

  } catch (e) {

  app.alert("Error During Save - " + e);

  }

  }

);

This script for the button in Acrobat Form.

var directory = "/Users/hasankoyuncu/Desktop/untitled folder/"

if (typeof(mySaveAs) == "function") {

  mySaveAs(this, directory, this.getField("BenefactorName").value + " " + this.getField("NameOfCharity").value + " " + this.getField("DonationDate").value + ".pdf");

} else {

  app.alert("Missing Save Function. Please contact forms administrator ");

}

My system is:

MacBook Pro (Retina, 15-inch, Mid 2014)

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You need to use the exportAsFDF method instead of saveAs.

Edit: fixed a small typo in the method name...

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

386

Likes

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

Save FDF as a silently and using name from Acrobat form field.

Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Dear All;
I would like to save the donation receipt information as a FDF, which is I already created through Acrobat Pro DC version 2019.008.20080 fillable form.

Again, through the code I found on this forum site, I can save the PDF form as a complete. But I want to save as a FDF, how to change the JavaScript code for this purpose?

Thanks in advance for your help

Code:@ !

I used the script below in my Javascript folder:

var mySaveAs = app.trustedFunction(

  function(oDoc, cPath, cFlName) {

  // Ensure path has trailing "/"

  cPath = cPath.replace(/([^/])$/, "$1/");

  try {

  app.beginPriv();

  oDoc.saveAs(cPath + cFlName);

  app.endPriv();

  } catch (e) {

  app.alert("Error During Save - " + e);

  }

  }

);

This script for the button in Acrobat Form.

var directory = "/Users/hasankoyuncu/Desktop/untitled folder/"

if (typeof(mySaveAs) == "function") {

  mySaveAs(this, directory, this.getField("BenefactorName").value + " " + this.getField("NameOfCharity").value + " " + this.getField("DonationDate").value + ".pdf");

} else {

  app.alert("Missing Save Function. Please contact forms administrator ");

}

My system is:

MacBook Pro (Retina, 15-inch, Mid 2014)

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You need to use the exportAsFDF method instead of saveAs.

Edit: fixed a small typo in the method name...

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

387

Likes

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
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

You need to use the exportAsFDF method instead of saveAs.

Edit: fixed a small typo in the method name...

Likes

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
Reply
Loading...
Nov 16, 2018 1
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Sirtry67​​​;

I don't have enough knowledge of JavaScript. Please Can you type some of the sample code.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

Please take look at the JavaSxript reference and let us know if it’s not clear.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Unfortunately I couldn't find a way to save the file in FDF format with this method.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

You couldn't find a way to export an FDF with the exportAsFDF method? Please show the code you tried and tell us how it failed. (Note the spelling error: it's exportAsFDF not exportAnFDF).

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

I am using below code for save as a PDF. But I would like to save as FDF with this method.

I used the script below in my Javascript folder:

var mySaveAs = app.trustedFunction(

  function(oDoc, cPath, cFlName) {

  // Ensure path has trailing "/"

  cPath = cPath.replace(/([^/])$/, "$1/");

  try {

  app.beginPriv();

  oDoc.saveAs(cPath + cFlName);

  app.endPriv();

  } catch (e) {

  app.alert("Error During Save - " + e);

  }

  }

);

This script for the button in Acrobat Form.

var directory = "/Users/hasankoyuncu/Desktop/untitled folder/"

if (typeof(mySaveAs) == "function") {

  mySaveAs(this, directory, this.getField("BenefactorName").value + " " + this.getField("NameOfCharity").value + " " + this.getField("DonationDate").value + ".pdf");

} else {

  app.alert("Missing Save Function. Please contact forms administrator ");

}

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

Yes, we understand that. You need to use exportAnFDF and perhaps create a myExportFDF function. Which part of this is giving you the problems? Please don't just as us to code it for you, our aim is to help you learn to solve your own problems.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Thank you so much. I appreciated.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

I get this error when I change the code.

Screenshot 2018-11-16 20.23.02.png

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

It's no good telling us just that you change the code. What do you change the code to? Did you observe, too, that it is not "ExportAsFDF" but "exportAsFDF"?

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Yes, I made a capital letter by mistake. Now it saves as a FDF but without using the updated field name.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

Again, you need to post your code... We can't help you without knowing the details of what you're doing.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

I used the script below in my Javascript folder:

var myExportFDF = app.trustedFunction(

  function(oDoc, cPath, cFlName) {

  // Ensure path has trailing "/"

  cPath = cPath.replace(/([^/])$/, "$1/");

  try {

  app.beginPriv();

  oDoc.exportAsFDF(cPath + cFlName);

  app.endPriv();

  } catch (e) {

  app.alert("Error During Save - " + e);

  }

  }

);

This script for the button in Acrobat Form.

var directory = "/Users/hasankoyuncu/Desktop/untitled folder/"

if (typeof(myExportFDF) == "function") {

  myExportFDF(this, directory, this.getField("BenefactorName").value + " " + this.getField("NameOfCharity").value + " " + this.getField("DonationDate").value + ".fdf");

} else {

  app.alert("Missing Save Function. Please contact forms administrator ");

}

Thank you in advance for your help.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

Seems fine... What was the result, then?

Likes

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
Reply
Loading...
Nov 16, 2018 0
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

Sir,

When saving as a PDF format, the file name is given according to the new information entered into the fields. However, the file name is always the same when save as a FDF.

Thanks

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

Ah, I see part of the problem.

In the documentation you will see that doc.exportAsFDF has multiple parameters. So when you call

exportAsFDF ( thepathnameyouwant )

it isn't treated as  a pathname. You need to use

exportAsFDF ( { keyname : thepathnameyouwant } )

where keyname is the name of the key that identifies the path.

Likes

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
Reply
Loading...
Nov 16, 2018 1
Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

I'm not very experienced for JavaScript. This form for a donation, thank you very much if you explain more.

Likes

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
Reply
Loading...
Nov 16, 2018 0
Most Valuable Participant ,
Nov 16, 2018

Copy link to clipboard

Copied

Change this line:

oDoc.exportAsFDF(cPath + cFlName);

To:

oDoc.exportAsFDF({cPath: cPath + cFlName});

Likes

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
Reply
Loading...
Nov 16, 2018 2