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

Export fdf using a button javascript

New Here ,
Jan 23, 2018 Jan 23, 2018

Hi,

I have no javascripting knowledge, is it possible to add an export .fdf javascript to a button in a pdf form?

seems simple but i can't seem to find an example?

Thansk

Adamsski168

TOPICS
Acrobat SDK and JavaScript
4.8K
Translate
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 , Jan 23, 2018 Jan 23, 2018

.You can use this script in a Button MouseUp Action:

this.exportAsFDF();

This displays a file Save As dialog for saving the FDF file. There is an input parameter for setting the file path. This won't work from a button script because specifying a path is a privileged operation. But it would work from an Acrobat DC Command. Look on the Actions panel. There is a feature for creating a new command. You can use this script with an input for saving the file to a specific name and location. Makes it a b

...
Translate
LEGEND ,
Jan 23, 2018 Jan 23, 2018

There are some built-in possibilities (e.g., doc.exportAsFDF), but they don't work with Reader. With Reader you can use JavaScript to build a string that's a complete FDF, but the user would have to somehow copy and paste it into a file.

Translate
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
New Here ,
Jan 23, 2018 Jan 23, 2018

Hi George,

thanks for the response. I am using Acrobat Pro and creating my own forms. I just wanted to add an export data button for the users so we can start to build on the data entered.

Thansk

Adam

Translate
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 ,
Jan 23, 2018 Jan 23, 2018

.You can use this script in a Button MouseUp Action:

this.exportAsFDF();

This displays a file Save As dialog for saving the FDF file. There is an input parameter for setting the file path. This won't work from a button script because specifying a path is a privileged operation. But it would work from an Acrobat DC Command. Look on the Actions panel. There is a feature for creating a new command. You can use this script with an input for saving the file to a specific name and location. Makes it a bit easier on the user, and make the functionality available to any open form.

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

Translate
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
New Here ,
Jan 23, 2018 Jan 23, 2018

Hi Thom,

Thats really helpful thank you.

I just need to find the next part lol

Translate
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 ,
Jan 23, 2018 Jan 23, 2018

I may not have been clear, but the doc.exportAsFDF method will only work with Acrobat, so if any of the form users will be using Reader, then this approach won't work.

Translate
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 Beginner ,
Jun 01, 2018 Jun 01, 2018
LATEST

Hey George,

I tried your suggestion with the string that contains FDF ...

I used this code and it worked ... not saying that it's optimized but the idea was great.

To mention that the script is sending this to a web-service I created that wraps just final terminators...

For more details I can be contacted ...

Code:

var all = "";

var fld = "";

var d = this.dataObjects;

var dn = this.numFields;

for (var i = 0; i < dn; i++) {

    if (this.getNthFieldName(i) != null) {

        fld = this.getNthFieldName(i);

        val = this.getField(fld).value;

        all = all + "<</T(";

        all = all + fld;

        all = all + ")";

        if (val != null) {

            all = all + "/V(";

            all = all + val;

            all = all + ")";

        }

        all = all + ">>";

    }

}

var contstr = "<</FDF<</F(" + this.path + ")/Fields["

contstr = contstr + all;

// this I got them from a file ... not sure how to create them

var footer = "]/ID[<960596C7FECA907F3E2BB93B81F03C30><08B586C4C0EF3DF1D2490646D78F587B>]/UF(" + this.path + ")>>/Type/Catalog>>"

// the string is now ready ... although there are some more lines to wrap in the web-service

// fix-header and footer also added in web-service, but all fields were added in the content

// according to FDF synthax

// prepare call for web-service

var err;

var err2;

var wsaddr = "http://localhost:59843/Service1.asmx?WSDL";

var wsaddrfld = "WSAddr";

var wsaddrfromfld = "";

// filter the characters for SOAP call

contstr = contstr + footer;

contstr = contstr.replace(/</g, "&lt;");

contstr = contstr.replace(/>/g, "&gt;");

// call the web-service

try {

    var myURL = wsaddr;

    try {

        wsaddrfromfld = this.getField(wsaddrfld).value;

        myURL = wsaddrfromfld;

    }

    catch (err2) {

        app.alert("JSErr.ToGetWebService:" + err2.message + " - at URL:" + myURL);

    }

    SOAP.wireDump = true;

    var myProxy = SOAP.connect(myURL);

    var testString = "<docbinary>This is test</docbinary>";

    var myStringObject = {

        soapType: "xsd:string",

        soapValue: "<docbinary>" + contstr + "</docbinary>"

    };

    var result = myProxy.SaveDocument(myStringObject);

}

catch (err) {

    app.alert("JSErr.:" + err.message);

}

// finally - done ...

app.alert("File was SENT - JS");

// **** EOJ ****

.......

Happy coding,

Sever

svr@rogers.com

Translate
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