Skip to main content
Known Participant
November 5, 2023
Question

IMPORT FDF WITHOUTH SUCCESS

  • November 5, 2023
  • 1 reply
  • 888 views

Good evening and good morning,

 

I'm having hard time trying to figure out a JS Code to import data from FDF files. Basically I have thousands of .fdf files saved in different Folders, this files have all the same name "TEST". My PDF Document has some textfields which I would like to populate accordingly to the value I write into a specific textfiled "NAME", the value will be always the name of one of the folders where a TEST.fdf is saved.

 

I put the following Code into the Javascript folder:

 

var importFDF = app.trustedFunction(function(doc, fdfPath) {
app.beginPriv();

var fdf = app.openFDF(fdfPath);
doc.importAnFDF(fdf);
fdf.close();

app.endPriv();
});

function importData() {
var Name = this.getField("NAME").value;
var fdfPath = "G:/_____/______/" + Name + "/TEST.fdf";
importFDF(this, fdfPath);
}

Then, I recalled the action through a button in my document: importData ( );

But the button just opens a random window, where I will have to go looking for my specific folder.

If I try to recall the action by importFDF(this, fdfPath); the Debugger says the fdfPath is not defined. Could anybody help me here? Also I'd like to ask, do you how to create the opposite action, so to extract values from the textfields in my Document ?

Thank you always in advance 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 5, 2023

The importAnFDF methods takes a file path directly as the input parameter. You don't need to use the openFDF method.

Known Participant
November 5, 2023

So, if I delete 

var fdf = app.openFDF(fdfPath); 

then it should work ?

try67
Community Expert
Community Expert
November 5, 2023

And change:

doc.importAnFDF(fdf);

To:

doc.importAnFDF(fdfPath);