I have created a Dynamic XFA form using Livecycle designer.I'm using pdf.js to get the form fields.But after enabling "enable usage rights" to the form it shows the form field length is 0. I'm using page.getAnnotations() of pdf.js to get it.
-
may i know why it is down voted – user_new Mar 29 '17 at 13:41
-
About the downvoting… there are some people around who downvote anything PDF and PDF forms. Anyway, how did you enable the usage rights? Acrobat or Reader Extensions Server? – Max Wyss Mar 29 '17 at 21:08
-
@Max Wyss..Thanks for reply.I enable usage rights using Adobe Acrobat 8 professional. Don't know what is happening but it is working perfectly if the form is static. – user_new Mar 30 '17 at 01:53
-
any solution...please suggest. – user_new Mar 30 '17 at 18:07
-
See joelgeraci's answer. – Max Wyss Mar 30 '17 at 22:11
2 Answers
If the form is static XFA, the PDF contains an AcroForm dictionary in addition to the XFA dictionary which is how non-Adobe viewers can handle static XFA. They don't handle the XFA, they read the AcroForm as though the XFA didn't exist. However, with Dynamic XFA, it is very likely that there are no form fields in the AcroForm dictionary until the viewer renders the XFA into a PDF... Acrobat does this automatically but other libraries that can't create a PDF DOM from the XFA DOM won't be able to. I doubt your issue has anything to do with usage rights other than the fact that saving the file caused Acrobat to wipe the PDF counterpart to the XFA.

- 4,606
- 1
- 12
- 19
-
I try to export both the files (static and dynamic) to XML 1.0 using acrobat professional and both are having same xml structure.Is there any workaround i can do it using javascript / angularjs. – user_new Mar 31 '17 at 02:07
-
-
In Acrobat, you can access XFA field values using "this.xfa." then the fully qualified field name. For example... var employeeName = this.xfa.form.form1.EmployeeName; – joelgeraci Apr 13 '17 at 14:22
The short answer is that XFA forms are not supported right now by pdf.js. See github issue here: https://github.com/mozilla/pdf.js/issues/2373
If all you want is low-level javascript access to your form data (which was my use case), I created a fork of pdf.js here: https://www.npmjs.com/package/@ckhordiasma/pdfjs-dist with the ability to hook into the xfa tree using a getXFA() function that I jammed into the source code.
// filedata: a file blob
const pdfSetup = filedata.arrayBuffer().then(function (buffer) {
const uint8Array = new Uint8Array(buffer);
return pdfjs.getDocument({ data: uint8Array }).promise;
});
const getXFA = pdfSetup.then(function (pdf) {
return pdf.getXFA();
});
getXFA.then(function(xfa){
console.log(xfa);
});