Geetings Experts:
I'm implementing additional security measures into my 'initialze' event, where I'll check some global variables and render the file unreadable if needed.
Which object and properties do I access to remove all my pages from the form?
I would like to createa a function that removes all the sub pages, leavning only the Matster Page, enable a label in the MasterPage and save itself.
I searched for xfa.layout and Page[n].remove() methods but cannot find any reference to these.
.presence = "hidden", fulfills my purpose but the pages remian visible and I need for a clean solution no pages are visible.
I'm advanced in C# but a novice in LC JavaScript, so any comment, reference or code snipet will be greatly appreciated
Thank you for your time,
Ivan A. Loreto – Computer Education Technician
LOMA LINDA UNIVERSITY | School of Allied Health Professions - Department of Physical Therapy
[PDF Development Platform]
Windows XP SP3
Acrobat Pro 9
LifeCycle Designer ES 8.2
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I think you are on the right track.
You set up one Master page with the pagination occurrence set to a max of 1. Here you can set our your security notice. Then set up a second master page as your main template.
In the design view the first page (page1) with be based on the security Master Page 1. Set this presence to hidden in the Object tab.
The initialise if statement criteria would include
page1.presence = "visible"; // show security notice
page2.presence = "hidden"; // hide all of the other pages
page3.presence = "hidden";
page4.presence = "hidden";
...
When the form is opened and the initialise criteria is OK then the user will see all of the pages (except the hidden security page). If the criteria fails then all of the pages are hidden and the security page made visible.
Hope that works,
Niall
ps I don't think you can remove Master Pages; but you can exclude pages from the form layout. Having two Master Pages makes this easier; one for the notice and another for the form itself.Also you can set the size of the security page to be much smaller (A5) and a different orientation (landscape).
Another option would be to hide all pages and have an app.alert for the security message. (although I think you always have to have at least one page visible).
Views
Replies
Total Likes
Hi,
I think you are on the right track.
You set up one Master page with the pagination occurrence set to a max of 1. Here you can set our your security notice. Then set up a second master page as your main template.
In the design view the first page (page1) with be based on the security Master Page 1. Set this presence to hidden in the Object tab.
The initialise if statement criteria would include
page1.presence = "visible"; // show security notice
page2.presence = "hidden"; // hide all of the other pages
page3.presence = "hidden";
page4.presence = "hidden";
...
When the form is opened and the initialise criteria is OK then the user will see all of the pages (except the hidden security page). If the criteria fails then all of the pages are hidden and the security page made visible.
Hope that works,
Niall
ps I don't think you can remove Master Pages; but you can exclude pages from the form layout. Having two Master Pages makes this easier; one for the notice and another for the form itself.Also you can set the size of the security page to be much smaller (A5) and a different orientation (landscape).
Another option would be to hide all pages and have an app.alert for the security message. (although I think you always have to have at least one page visible).
Views
Replies
Total Likes
Niall:
Thanks for your prompt reply. I appreciate it.
I was able to do it with a single MasterPager.
I just added a single page "SecMsg" that shows the security message and set it as "hidden" at design-time.
form.initialize event:
if(isHidden = true) {
SecMsg.presence = "visible";
Page1.presence = "hidden";
//all other pages are hidden
//Save PDF so that isHidden default value should be true. <---?
}
else {
//do nothing;
//shows all by default.
//hides SecMsg by default }
isHidden (boolean) is set at design time to false, when I change it to true at runtime, which is the best method to save the state of the variable so that the next time the form is loaded, the boolean var can hide the items?
Thanks again for the brain fuel,
Ivan A. Loreto – Computer Education Technician
LOMA LINDA UNIVERSITY | School of Allied Health Professions - Department of Physical Therapy
Views
Replies
Total Likes
Ivan,
Glad its working!
When changing variables, which need to be saved between different sessions, set the "preserve scripting" in the File / Form Properties / Defaults tab.
While you could set up a global variable in the Variables tab above, I am inclined to have a hidden textfield (or numericfield or checkbutton) and set this to false at design time; true at run time. I have had problems with global variables saving their new value (even with preserving scripting set).
In your if statement, the comparision operator should be a double "==". If you are using global variables then isHidden is fine. Just bear in mind that if you use a hidden field, then include .rawValue.
Using an Adobe grey background will make it appear that the file has closed and just the security message remains.
Lastly, set a password in the Security tab, otherwise someone could open the form in LC and reset the global variable / hidden field and unlock the form.
Good luck,
Niall
Niall:
Thank you for your sample form and detail responses. I'm so near completion!
I have also opted for the hidden field on MasterPage1 rather than a global variable.
I'm trying to grasp this LC JavaScript object model.
However, I'm having trouble accessing objects in MasterPage 1 at runtime.
For example, when I try to change SecMsg field:
var mPg = xfa.resolveNode("xfa.form.topmostSubform.#pageSet[0].MasterPage1");
mPg.SecMsg.rawValue = "New message";
I get : Error: null is not an object
I'm also writting a generic function that cylces thru a document and hides the pages.
Thus I can reuse it as script object on other forms I want to secure.
Here's my pseudo as I have not started work on this, yet.
for (int i=1; i = xfa.layout.numPages; i++;)
{
xfa.host.currentPage = i;
var curPage = xfa.resolveNode("xfa.form.topmostSubform.Page"+ i.ToString() );
curPage.presence = "hidden";
}//next page
Perhaps I'm not using xfa.resolveNode properlly? or is there another method?
Any ideas and feedgback would be appreciated.
I really appreciate your help, especially since my deadlines coming up fast.
Ivan A. Loreto – Computer Education Technician
LOMA LINDA UNIVERSITY | School of Allied Health Professions - Department of Physical Therapy
Views
Replies
Total Likes
Hi Ivan,
The particular syntax of Javascript in LC Designer is different from that used in Acrobat and different (as I understand it) from core javascript and other applications. There are several free guides on the Adobe web site which cover Acrobat and LC:
http://www.adobe.com/go/learn_lc_scriptingBasics
http://www.adobe.com/go/learn_lc_scriptingReference
http://www.adobe.com/go/learn_lc_formCalc
http://www.adobe.com/devnet/livecycle/articles/Adobe_XML_Form_Object_Model_Refer ence.pdf
http://www.adobe.com/devnet/acrobat/pdfs/lc_migrating_acrobat_xmlform.pdf
And a very handy resource (it goes back to version 6, but is still applicable):http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf
JP Terry's book on LC Forms is very good and we use www.pdfscripting (which is a subscription service). If you are going to be doing a lot of LC Designer work, these may be of help.
I am not a coder, so I going to try and work through your script. Bear with me if you already have this sorted...
The script looks ok and you are using the resolveNode method correctly. Seeing topmostSubform in the resolveNode indicates that you imported an existing document into LC. This is fine, but sometimes it restricts some of the functionality.
For starters I think that mPg is returning null. You can use the following in your script to see what is happening (debugging) and then comment it out:
console.println("mpg: " + mPg);
Then when previewing hit control+J to bring up the javascript console, then will show the value of mPg when that script executes.
Try deleting the SOM up to #pageSet:
var mPg = xfa.resolveNode("#pageSet.MasterPage1");
The javascript console will show you when the script is working.
In relation to the loop, I would advise a few changes:
for (var i=1; i <= xfa.layout.pageCount(); i++)
{
var vPage = ("xfa.form.topmostSubform.Page" + i).toString();
//console.println("vPage: " + vPage);
var curPage = xfa.resolveNode(vPage);
curPage.presence = "hidden";
}//next page
There are a few things here:
Have a crack off that and hopefully you can get it to work,
Niall
ps another tip, if you want to reference an object in script. First click on the object you want to script for and then scroll (or click on the master page) for the object you want to reference. Click inside the script editor and then when you move the mouse back into the form, press and hold Control, this will turn the mouse into a "V". When you click on the object you want to reference it will insert the SOM into the script. If it needs the resolveNode it will automatically put that in for you. Holding Shift and Control will insert a fully resolved node.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies