How to Change A PDF Form to 'Read-Only' Before the User Submits

Script

for (var i = 0 ; i < this.numFields ; i++) {

var f = this.getField(this.getNthFieldName(i)) ;
if (f.type != "button") // do I have to change the word between " " with the name of my button which I put on my PDF? name of button is "Valider"
{
f.readonly = true ;
}
}

Finding The Right Solution For Your User

Interactive PDF forms are very useful for a variety of projects. It is a great alternative to web forms while keeping the same interactive attributes. Interactive PDF forms are not only easy to create, they are accessibly on multiple platforms creating a solution for a wide variety of needs.

In the first tutorial I go over how to create the actual form with text fields, buttons, radio buttons and the reset / submit actions. Adobe Acrobat has a lot more to offer than just basic forms, and is an incredible tool for businesses. There are specific situations where the fields need to be editable for the user to fill out, but when the information is submitted to its designated destination, the information needs to be locked so that it cannot be changed on the receiving end.

There are a few different solutions to this such as having the user save as an image and then email, or to change the form to read-only on their end before sending. As I have mentioned in several other hubs, the ultimate goal is the make the task as easy as possible for the user. By requiring the user to do extra work it leaves a lot of room for error, whether they forget to complete a step or they don't understand the instructions. Not only is this not efficient for your user, it may also deter users from completing the information that you need out of frustrations.

Choose "Run a JavaScript"

Next, go to the drop down for “Select Action” and choose “Run a JavaScript”.Once you choose this, another box will appear that will allow you to enter code.

Select Trigger "Mouse Up"
Select Trigger "Mouse Up"

Adding a Simple Script

The best way to make a PDF form read-only on the receiving end is to add a simple script to a button that will be selected before submitting the form. This button can be as simple as adding text such as “I agree that this information is correct” or even saying “by clicking here you are submitting your digital signature”. The button itself when selected will run a quick script that will make the PDF read-only, and then the user can select the “submit” options to complete the task. The process listed below is to make all fields in the entire form read-only with one script.

The first step is to create a space on your form for the button with the text that you choose.

Once you set your “general” options for your button, go to “actions” and select “Mouse Up”.

Add The Following Script

Add the following code and choose “ok”:

for (var i = 0 ; i < this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f.type != "button") // do I have to change the word between " " with the name of my button which I put on my PDF? name of button is "Valider"
{
f.readonly = true ;
}
}

Once you choose ok that screen will close, and you should now see the added action in your action field.

When it has been successfully added, you will see that it appears in the "actions" field.
When it has been successfully added, you will see that it appears in the "actions" field.

Now You Need The Button to be Required

Save your PDF Interactive form, and you have now created a button with a script to make the form 'read-only' before sending it to the targeted recipients.

For this to work effectively, you need to make sure the user checks the button that you have created. You now need to make that field required.

Go back to your button settings and choose the “general” tab. Under “common properties” check the box “required”. Choose “close”, save your form again and now the user must click that button to be able to send the form. When they choose that required button the form will be changed to a read-only PDF.

Interactive PDF forms are a great alternative to web forms, and can be used for a variety of projects. They are easy to create, accessible for a wide variety of users and can be printed, saved or emailed when submitting.

Other How-To Articles

  1. How To Create Interactive PDF Forms - this is a step-by-step tutorial that will show you how to create your own custom PDF form that can be used for a variety of projects.
  2. A Guide To Graphic Design Templates - this includes setting up publication templates, margins, bleeds and other guru tips and tricks using Adobe InDesign.
  3. How to Create Your Own Joomla Template - a step-by-step tutorial that will walk you though how to create your own custom Joomla template, work with PHP programming language and upload to your own Joomla website.

©Copyright 2012 by DAPPLE DESIGNS (MELISSA MILLER)

More by this Author


Comments 10 comments

Carol 3 years ago

This is helpful, thanks! However, when it turns into a read-only form the Submit/Email button is deactivated as well, so the user can't submit the form. Any help with that would be appreciated.


dappledesigns profile image

dappledesigns 3 years ago from In Limbo between New England and the Midwest Author

Did you create the read-only button after the submit button was created?


Eros 3 years ago

This was very helpful, thanks. However, is there any way to turn the read-only form back to accessible, if something needs to revise etc.?


Pablo 3 years ago

Thank you very much!! I've been looking for a simple script to lock pdf file for quite a while. This fits the bill exactly.


dappledesigns profile image

dappledesigns 3 years ago from In Limbo between New England and the Midwest Author

@Eros - only the user that filled out the form can change it back to revise. They can uncheck the required button and from there edit and resend. The recipient can not change the information.

@Pablo - I'm so glad you found it helpful!


Eros 3 years ago

I still cannot make it work like would: I can create the button with script which makes the form read-only. But I cannot turn the document back to read-and-write, even if the button is unchecked / read-only check removed / entire button and script removed.


Eros 3 years ago

further to my previous post: the reason seems to be that even if the check mark is removed from the check box (which by the way needs to be done in editing mode since the script also turn the check box as read-only), the read-only status is left on all of the other fields and if something needs to be revised, first you need to remove the read-only mark in editing mode before you can edit the field. What I would like to have is that that when the (hidden) check mark is removed, all fields turn again editable. Hpe you can understand what I want :)


dappledesigns profile image

dappledesigns 3 years ago from In Limbo between New England and the Midwest Author

@Eros - I think I understand now what you are asking. By choosing the "read-only" button, the script is initiated to run. Depending on the version of software, it will sometimes default to run when submitted. When you go in to set the "mouse up" options of the action on the button (the check mark to run the script) you should be able to go in and choose when to run the action. For example, if you choose for the script to run only when the form is submitted, as opposed to when the box is checked. You can also choose to add a "reset" button on the form. In the reset options, you can have it reset all fields and scripts when used. This will clear all info already put in the form, but it will release the script.


Vanessa 3 years ago

Thank you thank you thank you... i've been searching for days through web pages and forums and no help at all until I found your script! Works like a charm!


Vanessa 3 years ago

Me again... I found that this doesn't work after you enable usage rights... please help!

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working