Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

importDataObject

Jan_Babicky
Level 3
Level 3

Hi all,

I have a form, that uses a button to add attachment to form with specific index. Now with reader 9 the functionality seems to be awkward.

Correct me if I am wrong, but If I use this code:

var myDoc = event.target;

myDoc.importDataObject("test");

a file should be added to the PDF form with index test. Now if I call the code one more time, I would expect the attachment to be replaced (worked with reader 8), however with reader 9, two attachments are present and only one has the "test" index.

Any ideas what to do with this? I want to avoid indexing based on number sequence.


Thanks

Jan

1 Accepted Solution
_Nith_
Correct answer by
Level 10
Level 10

call the following method before you add; let me know the response.

myDoc.removeDataObject("test");

Nith

View solution in original post

0 Replies
_Nith_
Correct answer by
Level 10
Level 10

call the following method before you add; let me know the response.

myDoc.removeDataObject("test");

Nith

View solution in original post

Jan_Babicky
Level 3
Level 3

Hi Nith,

that is what I did, I also added one more condition before this line to check whether attachment is present or not (based on hidden field).

I wanted to avoid user hitting cancel at the attachment dialog box and having the attachment removed. (I don't know how to catch cancel event on the system file dialog box)

Thanks a lot,

Jan

_Nith_
Level 10
Level 10

Var attResult = doc.importDataObject("yourObjName");

// attResult will be false if the user hits the cancel button; otherwise it will be true.

Hope this may help you to proceed.

Nith

arunpriyan89483
Level 2
Level 2

Hi,

I tried to add the attachment in PDF form. I wanted to convert the attached file to xml file format while submitting the form. Please help me to resolve this issue

var sFile = "myFile";

myDoc.importDataObject({cName: sFile});

var myDataObject = myDoc.getDataObject(sFile);

var sFileName = myDoc.path;

Var item = myDoc.get

app.alert(myDataObject +"f" +sFileName );

radzmar
Level 10
Level 10

Sorry, your script and description doesn't make much sense right now: Do you want to convert a whatever file into an XML during import? Why? What kind of file do you try to import and for what exactly?

arunpriyan89483
Level 2
Level 2

Hi,

Thanks for your response!!

Tool: Adobe acrobat LiveCycle Designer ES 8.2

I’m creating PDF form. In that form, I have to attach the spreadsheet.  In submit click, have to convert all the data to XML format (including spreadsheet data). The converted XML data will insert to Database.

Searching the script for add the attachment in PDF form. I used below script and able got the filename alone. I want to get data which is present in spreadsheet and that will convert to XML format while submit click.

var myDoc = event.target;

var sFile = "myFile";

Var a=myDoc.importDataObject({cName: sFile});

var myDataObject = myDoc.getDataObject(a);

var sFileName = myDoc.path;

Please advise me urgently!!

radzmar
Level 10
Level 10

You cannot convert a native XSL or XSLX file into an XML by JavaScript. Why don't you export the data from Excel spreadsheet directly as XML file and then import this XML into your form?

Anyway, I think you should first read some tutorials to get an idea of what is possible.

http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/

http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/

LiveCycle Blog: XML per Skript in Adobe Reader importieren//Import XML via Script into Adobe Reader

Display an XML Spreadsheet