Expand my Community achievements bar.

Saving Fillable Form as non-fillable PDF

Avatar

Former Community Member
I need some help with LiveCycle.



I've created a form that will be sent to several people to fill out. Once they fill it out, they will need to save the form as a non-fillable file (normal PDF?) and send on to others to be read-only. The form will not come back to me.



I cannot figure out how to enable the form to be saved as a normal, non-changeable PDF.



Also, the only option seems to be that the form is returned to me. I don't want that, either.



Thank you!

Tricia
385 Replies

Avatar

Level 10

Hi,

This is an excellent opportunity to look at the function in detail.

Basically you need to create a similar function to unlock all the fields. This is very straightforward.

First go into the 'myScriptObject' and copy all of Paul's function. Then go below his function and paste. You now have two separate functions in the one script object, this is perfectly normal - you just need to rename the new one:

/*************************************************************************************

Function: UnLockAllFields

Description: This function will unlock all fields.

IN: The parent subform. It could also be an element that contains subform like form1

OUT : nothing


**************************************************************************************/


function UnLockAllFields(myParentObject){

          var allChildElements;

          ...

See how I have called it 'UnLockAllFields'.

Now you need to edit this new function. Paul has two lines that set the access of the currentElement to 'readOnly'. You need to change this in your new function to 'open' (in just two locations):

currentElement.access = "open";

The last step is to call the function in your 'reset' button. I would put this line at the start of the script:

myScriptObject.UnLockAllFields(form1);

Should work - good luck,

Niall

Avatar

Former Community Member

Hi Niall,

I've copied/pasted/renamed Paul's function just like you said, but it doesnt work. In the reset button i already have script (again written by you of course ) and that works but the form stays unfillable. I also tried to place "myScriptObject.UnLockAllFields(form1);" before it and after it as well. When i tested, it doesn't work.

here is the file with last modications:

https://acrobat.com/#d=tp-spETA1mR9w*VzMpJXig

Marko

Avatar

Level 10

Hi Marko,

Here is the form back: https://acrobat.com/#d=garF1g40Y2T-s294LxnVOg

There was a line that I neglected to highlight to you.

if(allChildElements.item(j).className == "subform"){

     UnLockAllFields(currentElement);

}

Basically this is testing if the currentElement is a subform AND if it is, the script reruns the function, this time passing the subform in as the parameter. This basically ensures that all objects are locked, no matter how deep they are buried in nested subforms.

That should get you out of the blocks,

Niall

Avatar

Former Community Member

Hi Niall,

everything works now...

I really don't know how to thank you for all your patience...

Stay beautiful

Marko

Avatar

Former Community Member

paul,

how to create the fComment variable in that form? seems that i couldn't find how nor copy it to my form. is it some kind of object or a class something?

Avatar

Former Community Member

Thanks paul for this sample script. It is very helpful...

I have used this script in my form as well to lock the fields. It works great. However, I am also trying to lock the fields that are placed in the masterpages too. When I looked at the myScriptObject, I can see that it locks the fields placed inside the subforms and all other fields in the form but not the ones in the masterpage. But in my form, I also have some Text Fields, Date fields and Image fields (for company logo) and this comes under Masterpage (page1). How can I modify this myScriptObject so it locks the fields inside masterpages as well?

Avatar

Level 10

Hi,

I think that you might have difficulty here. If you only have a few objects, it might be better to specifically lock these master page objects one at a time.

After the function is called, script like this should work:

xfa.resolveNode("#pageSet.Page1.companyLogo").access = "readOnly";

Niall

Avatar

Former Community Member

Thank you Niall...makes sense..I will probably add this to the click event of the Lock fields button to control the fields in the masterpages.

When I was trying to do this, I just found a strange behaviour with this script. When I click the "Lock Fields" button, the fields that are in the Masterpage 1 (like the date field, company logo field, etc..) is reseted to default and these fields become empty even when they are filled. Why is that happening? not sure whats causing it..

Avatar

Former Community Member

hi Niall...never mind that. I found what was causing the fields in the masterpages to get resetted. It wasnt the original script. I tried to modify the original script so it can hide the buttons in the form as well so I replaced this sections of the original code:

//If the objects are fields and they are set to mandatory (validate.nullTest) then we will set the border.fill.color - dependant on object type

                    else if(currentElement.className == "field"){

                              //CHeck to see if the field is a button - do not lock buttons

                              temp =  currentElement.name;

                              if (temp.substring(0,6) != "Button"){

                                        currentElement.access = "readOnly";

                              }

 

                    }

to this:

//If the objects are fields and they are set to mandatory (validate.nullTest) then we will set the border.fill.color - dependant on object type

                    else if(currentElement.className == "field"){

                              //CHeck to see if the field is a button - do not lock buttons

                              temp =  currentElement.name;

                              currentElement.access = "readOnly";

                              //check to see if the field is a button and hiding the buttons

                              if (temp.substring(0,6) == "Button"){

                                        currentElement.presence = "invisible";

                              }

 

                    }

and thats why the other fields in the masterpages were getting invisible as well. Still cant understand what I did wrong here..maybe some logical mistake. anyhow, I scrached that idea and I am just hidding the buttons by adding a script to the click event itself since I will be doing the same for other fields in masterpages...

So thank you for your support. It helped.

Avatar

Former Community Member

Hi Niall, 

I am back again with an update..I found something strange with my scripts since they are not working the way I would have hoped for. Can you plz help me understand what I am doing wrong!

In my last post I had mentioned to you that for some reason the fields in the Masterpages are getting reset to default when I modified paul's original script so the buttons in the fields are also "hidden" when user clicks on "lock fields" button. Here is my last post: http://forums.adobe.com/message/4067867#4067867

Basically, the reason for why I was trying to do the above cuz I am trying to hide the "Add Row" and the "Delete Rows" buttons for the dynamic rows in the form as well. So i thought i will try a different method this time. Further to that, I scratched that idea and instead added the scripts to the "Click" function of the button itself like this:

form1.#pageSet[0].Page1.ButtonFinalizeForm::click - (JavaScript, client)

myScriptObject.LockAllFields(form1);

//script to lock the fields in the master pages

companyLogo.access = "readOnly";

DateTimeField1.access = "readOnly";

DropDownList1.access = "readOnly";

TextField1.access = "readOnly";

ButtonResetLogo.presence = "invisible";

//script to hide the add row and delete row buttons in the form

form1.pageSubform.dynamicSubform.addRowbtn.ButtonaddRow.presence = "invisible";

//couting the number of dynamic rows in form and starting loop to hide the delete row button

var countRows = form1.pageSubform.dynamicSubform.Table1.Row1.instanceManager.count;

for(var i=0; i<countRows; i++){

          form1.pageSubform.dynamicSubform.Table1.resolveNode("Row1["+i+"]").deleteRowBtn.ButtonDeleteRow.presence = "invisible";

}

From the above scripts you can see that I am doing the following:

Step 1: first locking and hiding the fields in the Masterpage content first.

Step 2: Then, I am hiding the "Add row" button in the form

Step 3: Next I am running to loop and hiding the "Delete Row" buttons in the tables inside the form.

Strange Behaviour:

Case 1: I have noticed that when I click the lock field Button now, it hides the buttons inside the form but the fields in the masterpages are reset to default, Meaning the filled content inside these fields only in masterpages are deleted and also the script to lock these fields are resetted as well so they dont work.

Case 2: But, if i remove the code to hide the "Add Row" button (as mentioned in Step 2), the rest of the script works fine. In this case, the delete rows buttons are hidden, the rest of the fields are hidden (as per the original code) and also the fields in masterpages are locked as well.

So here, I find that the problem is when I add this script to hide the "Delete Row" button inside the form:

//script to hide the add row and delete row buttons in the form

form1.pageSubform.dynamicSubform.addRowbtn.ButtonaddRow.presence = "invisible";

I have no idea why this is happening. Can you plz help me understand how I can overcome this?

Avatar

Level 10

Hi,

I'm out of the office, so can't upload an example. However the issue of master page objects reverting to default has been acknowledged as either a "bug" or a "feature" by Adobe. I can't remember which. What I do know that it is not possible to prevent this behaviour.

One option would be to set all of the objects on the master page to readOnly and to have a global binding (eg the default). Then in the first design page set up a subform with all of the master page objects replicated. Have a button "Set up this form", which would show the subform, allowing the user to fill in their data. Once they do this it will appear on the master page (global binding). The subform would also include a "Finish"/"OK" button, which would hide this subform again.

Then when the LockAllFields function is called it will lock the subform and the objects on the master page are already locked..

Make sense?

Niall

Avatar

Former Community Member

HI Niall,

Thanks again buddy..At first when I read your post, I wasnt sure what you meant but after re-reading it a few times and also learning a bit on binding etc, it then made clear sense. :-)

I tried your method and it did work. What I did here was, I inserted 2 subforms (1 named "InitialFields" and the other "FinalReadOnlyFields") in the masterpage and both of these had the duplicate fields of the same that were binded using global like you had suggested. When tested, it worked. The read only fields still had the contents that was inserted through the fields in the "InitialFields" subform even after the lock field buttons were clicked. So this bit was good..

However, the next part wasnt the one that best suited to my needs. This is the part of adding more buttons for "Set up this form" and the "Finish/Ok" buttons. I understand now on the reason for this workaround and why you had suggested but I just didnt want to add more buttons to my users since I already have enough buttons on the form. Didnt want to scare my users with all of these buttons. lol..So instead, I thought of trying another method by hiding the "FinalReadOnlyFields" subform first during the form initilization and then show these fields later when the user clicks on the Lock field button and then hide the "InitialFields" subform fields in the end. This obviously didnt work as well since I stepped into the same problem as I had before i.e the fields get reseted again to default so that means the fields in "FinalReadOnlyFields" subform always stayed hidden. 

So in the end, the best solution for me is to move all these fields from the masterpages to the actual form itself. This seems to solve all the issues as long as I have these fields inside the forms and not in the Masterpages. However, I just had to re-design the scaling part of these form elements since I moved from masterpage to the page subforms. (I hate scalling each fields..I spend 1/2 my day doing it..lol). Also by using the global binding method, I can re-populate the 'companyLogo' fields in my other masterpages with no problem. So far so good...

Thank you again Niall...I am glad I stumbled upon the previous problem since I was able to learn new things through this..Thank you for your support. Its positive supports like these that helps out noobs in the learning process...Much obliged!

Avatar

Level 2
Hi Paul,



I'm also interested in your code. Could you please send it to me? My email is nak.morris@gmail.com



thanks in advance.

Avatar

Level 2
Thanks, Paul.



I am setting it for version 8.1+ Will continue to experiment.

Avatar

Level 2
YES! The settings were the problem. THANK YOU!

Avatar

Former Community Member
Could you please send the script to me as well. My email is JStellato@NewLifeME.org



THANKS!!!

Avatar

Former Community Member
Can you send me the script as well:

samra_sm53@hotmail.com or

samra_sm53@yahoo.com

Avatar

Former Community Member
Mr. Guerette,



Request a copy of this sample. I am the form manager for federal agency.



Thanks,

Michael



(Sent you my email addy)