Is there some magic behind event.target.importTextData() that I'm missing?

Avatar

Avatar

GregFullard

Avatar

GregFullard

GregFullard

14-02-2016

Hi All

I'm busy building a form for a client who needs to import a portion of the form from a local file. The scenario is as follows:

1. User will fill in some portions of the form

2. Then the user will import some data which will populate a table in the form

Since I don't want to wipe all the data that the user has captured, I can't use xfa.host.importData.

As a result, I'm using the loadXml method on the data DOM, followed by a remerge.

This works well, however, for loadXml to work I have to supply the XML as a string. My workaround was to create a hidden text field and load the XML from there. It works nicely.

Last remaining problem is getting the xml from the file system into the text field.

There's limited information about how to do this, but it seems I need to use the acrobat method importTextData(), which seems simple, but never works.

I've followed Stefan's advice at this link: Import data from text file . Seems simple but simply does not work

My code is as follows:

var returnCode = event.target.importTextData();

xfa.host.messageBox("ReturnCode: " + returnCode);

I always get a returnCode of 1, which means "Error: Cannot Open File"

What seemed like a simple issue, is turning into a nightmare, so I'm assuming I'm missing something obvious here.

Any help will be appreciated

PS. I'm also open to other suggestions

Greg

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar

GregFullard

Avatar

GregFullard

GregFullard

15-02-2016

Indeed. My data is tab delimited

Avatar

Avatar

8_BIT_PLATOON

Avatar

8_BIT_PLATOON

8_BIT_PLATOON

14-02-2016

Was quickly checking this out:

http://help.adobe.com/livedocs/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.h...


"Each row must be tab delimited"

--> Is the text file data tab-delimited?

The method importTextData() seems to only support tab-delimited files --> so the name of the function is misleading.

The very last line of the article says:

"The data file can be a spreadsheet or a database."

I'll try spend some time later today checking what i've done in the past... (refresh my brain)

Goal: get Adobe Reader/Acrobat to read the raw contents of any file.