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

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

Explorer ,
Nov 16, 2018 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)

TOPICS
Acrobat SDK and JavaScript

Views

1.0K

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 1 Correct answer

Community Expert , Nov 16, 2018 Nov 16, 2018

You need to use the exportAsFDF method instead of saveAs.

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

Votes

Translate

Translate
Community Expert ,
Nov 16, 2018 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...

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
Explorer ,
Nov 16, 2018 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.

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
LEGEND ,
Nov 16, 2018 Nov 16, 2018

Copy link to clipboard

Copied

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

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
Explorer ,
Nov 16, 2018 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.

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
LEGEND ,
Nov 16, 2018 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).

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
Explorer ,
Nov 16, 2018 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 ");

}

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
LEGEND ,
Nov 16, 2018 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.

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
Explorer ,
Nov 16, 2018 Nov 16, 2018

Copy link to clipboard

Copied

Thank you so much. I appreciated.

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
Explorer ,
Nov 16, 2018 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

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
LEGEND ,
Nov 16, 2018 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"?

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
Explorer ,
Nov 16, 2018 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.

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

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
Explorer ,
Nov 16, 2018 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.

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 ,
Nov 16, 2018 Nov 16, 2018

Copy link to clipboard

Copied

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

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
Explorer ,
Nov 16, 2018 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

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
LEGEND ,
Nov 16, 2018 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.

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
Explorer ,
Nov 16, 2018 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.

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 ,
Nov 16, 2018 Nov 16, 2018

Copy link to clipboard

Copied

Change this line:

oDoc.exportAsFDF(cPath + cFlName);

To:

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

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
Explorer ,
Nov 16, 2018 Nov 16, 2018

Copy link to clipboard

Copied

LATEST

Dear Mr. try67​​

Thank you so much. You are awesome!

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