Expand my Community achievements bar.

Locking/Protecting/Flattening? XFA form


Level 1

Hi there!
I'm working on a dynamic form (.pdf) and i need to somehow lock all fields (really lock all fields). I already managed to change all fields .access property to either readOnly/Protected. The problem is that if someone opens a form in Acrobat it is still possible to use menu item "clear form" and booom all the data is gone. I also know it would probably be possible to unlock all fields again using js console in Acrobat (while this is rather rare case and i don't care). I want to prevent the menu item "Clear form". Is there any way I can stop this feature and offer clearing form only in certain form state (and only using a button within a form which i will hide/disable in the final state using script?)

My second questions is related to flattening - is it possible to flatten the form with javascript if a client use Reader and not Acrobat?

Any other solution that could prevent changes to document would be helpful.
Many thanks for your help,


3 Replies



Hi There,

Can you provide more details on your usecase as to why are you using dynamic form and do not permit others to edit form fields? may be your usecase does not need dynamic forms and you may flatten them before sending it to other users.

You may consider using digital signatures in your PDF to lock fields which cannot be modified by others, in case somone manages to do it - then the signature would be broken telling you that there are modifications to the form fields



Level 1

Hi Santosh,
Thank you for the idea of digital signatures.

Let me explain what i want to achieve once again.

The form needs to be dynamic (it will be downloaded by users from our intranet site) and it has two expandable tables and few other features that are needed - thats why it has to be dynamic.

Most of users have Adobe Reader (but some may have Acrobat).

The form shouldn't be sent via e-mail or any other way due to security requirements.

The form filler should be able to fill the form and either print it or lock&save for printing/archiving later.

The problem is that such "locked" document can be altered using Acrobat Pro thats why i'm trying to somehow prevent it (at least the menu item "clear form").

Or maybe there is a script that could popup a msgbox on docReady event (if client use Acrobat) with information that "pleas use adobe reader to fill in this form, blablabla" and then close the doc?

Digital signature does not exist in my form and my client don't want it so i need another solution.

Thank you for your help.




Level 2
  1. You can't flatten an XFA file in Acrobat or Reader (Acrobat cannot edit XFA files at all). You can only flatten PDFs (AcroForms), and without jumping through some very complicated hoops involving EchoSign, you can only do it in Acrobat.
  2. Preventing someone else from altering a completed form is why digital signatures were invented. There's no other way.
  3. You can't force a document to close itself.
  4. You can't disable any of the menu items; unless the form has been signed it will always be possible to clear it again.
page footer