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

How can I check if an attachment is an xfa form

bugrake
Level 2
Level 2

I have a button on the form to help users add attachements,  I can get the name / path / size  / filetype - but is there a way to check if the new attachemnt is an xfa form ?

thanks

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

You could use the doc objects openDataObject method, so;

var oDoc = event.target.openDataObject("MyAttachedFile");

console.println(oDoc.xfa !== undefined);

This will print true if the attachment is a XFA form.  Opening a form this way still fires all the normal events,  initialise, validate etc so if there are any exceptions then I don't think it will open correctly.

Regards

Bruce

View solution in original post

6 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

You could use the doc objects openDataObject method, so;

var oDoc = event.target.openDataObject("MyAttachedFile");

console.println(oDoc.xfa !== undefined);

This will print true if the attachment is a XFA form.  Opening a form this way still fires all the normal events,  initialise, validate etc so if there are any exceptions then I don't think it will open correctly.

Regards

Bruce

View solution in original post

bugrake
Level 2
Level 2

thanks bruce for a quick reply - will check this option when i get back from vacation regards steve

bugrake
Level 2
Level 2

Bruce,

It worked - XFA forms are flagged

var oDoc = event.target;

if (oDoc.dataObjects != null) {

          var d = oDoc.dataObjects;

          for (var i = 0; i < d.length; i++) {

                              var sizeKB = (d[i].size/1024).toFixed(1);

                              app.alert("file: " + d[i].path + ";\nSize: " + sizeKB + "KB;\nDate modified: " + d[i].modDate + ";", 3, 0, "Attachment Information");

                              var oObj = event.target.openDataObject(d[i].path)

                              if (oObj.xfa != undefined) {

                                        app.alert("This is an XFA Form",3,0,"XFA check");

                              }

          }

}


Is there a way to check the attachments for Interactive forms and forms with annotations ?

I tried

var annots = oObj.getAnnots({nPage:0});

but this ain't working,

thanks

Steve

_Bruce_Robertson
Level 10
Level 10

Hi Steve,

I don't think I can help you, I didn't even think that an XFA form could have annotations so this is something I haven't tried.

Good luck,

Bruce

TundraSteve
Level 8
Level 8

var oDoc = event.target;

var annots = oDoc.getAnnots({nPage:0});

console.println("Number of Annotations: " + annots.length);

Static XFA documents can have annotations, dynamic can not.  The above worked for me

bugrake
Level 2
Level 2

The problem I am trying to solve is the blocking of intelligent or annotated attachments to our livecycle designer form, as these are causing our downstream processing system to crash.   The form requires a number of attachments, and everything was working fine until about 12 months ago when customers started adding more complex pdf's.   The form already does checks for attachment file size and file type, I was hoping to extend these checks to block "non flattened" attachments or alternatively to trigger some javascript to flatten the attachment and re-attach - or prompt the user to re-attach.

So  oObj.xfa != undefined  worked for both dynamic and static xfa attachments

but oObj.getAnnots({nPage:0})  does not seem to work when applied to an attachment object. Should it ? If so I will keep trying !

I also read flattenPages() will not work in Adobe Reader so the option to immediately write out a flattened version of the attachment (and attach the flattened version) will not work either.  

Looks like I may be not be able to achieve this checking/filtering of attachments (apart from xfa forms) from within the form.