Export fdf using a button javascript

Jan 23, 2018

Copy link to clipboard

Copied

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

.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.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

2.1K

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

Export fdf using a button javascript

Jan 23, 2018

Copy link to clipboard

Copied

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

.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.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

2.1K

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

.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.

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

Hi Thom,

Thats really helpful thank you.

I just need to find the next part lol

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...
Jan 23, 2018 0
sever_s_ LATEST
Jun 01, 2018

Copy link to clipboard

Copied

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

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...
Jun 01, 2018 1