Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Calling Master Pages during Run-time

Avatar

Level 10
Hi,



I have a dynamic form with flowing tables. Based on user input on page 1 (Master Page 1), we want subsequent pages (based on Master Page 2) to have 1 of 5 different logos (image fields) on the top right hand corner.



I have scripted a field on page 1 to change the visibility of the 5 image fields on Master Page 2, depending on the choice of the user. The difficulty is that while this works on the first instance of Page 2, as the user adds rows to the table and it flows onto the next page, the logo disappears.



Reading through forums, it appears that putting dynamic content (such as changing the visibility of the image fields) on Master Pages can cause difficulties.



A solution I am trying to get to work involves having 5 separate Master Pages. Each one has the static image field. Then what I am trying to do is get Page 2 to use the appropriate Master Page depending on the choice of the user.



I have tried to get conditional breaks in the pagination tab to force a different Master Page, but cannot get this to work at all.



Would be grateful for any ideas.



Thanks in advance.



Regards,



Niall
6 Replies

Avatar

Level 10
Solved the problem and I am posting the workaround...



I gave up on trying to call the master pages and went back to JP Terry's book.



He provided the script for changing images:



imageField1.rawValue = image1.value.image.value;



This worked a treat, as I moved the five static images to a body page and made them invisible. Then I put an image field in the master pages. A simple script based on JP Terry's example pushed the applicable logo into the image field on the master pages. Worked first time - I would strongly recommend his book as it is packed full of great tips and tricks!!!



N.

Avatar

Former Community Member
Hi Niall,



Could you post details on your script? I am trying to do something similar, and this sounds like it could really help.



Thanks,

Erika.

Avatar

Level 10
Hi Erika,



For clarity, I just kept the form with 2 Master Pages. The logos are on Master_Page2.



Start off by adding an Image Field (logo) to Master_Page2. Set the presence to visible and the legend to none. Do not give this Image Field a URL



Then on page 1 of the form insert five Static Image objects. Set the URL for each of these static objects with your five logos. Remember to embed the image data. Then set the presence to invisible.



Now for the script. I had a drop-down list (group) with five company names. I had an invisible numeric field watching the value of this drop-down list and the numeric field had the following script in the calculate event (Javascript):



var oSubform = xfa.resolveNode("xfa.form.form1.#pageSet[0].Master_Page2.logo"); //This references the Image Field on the Master Page



if (form1.p1.group.rawValue == 1) {

oSubform.rawValue = company1_logo.value.image.value;

}



if (form1.p1.group.rawValue == 2) {

oSubform.rawValue = company2_logo.value.image.value;

}



if (form1.p1.group.rawValue == 3) {

oSubform.rawValue = company3_logo.value.image.value;

}



if (form1.p1.group.rawValue == 4) {

oSubform.rawValue = company4_logo.value.image.value;

}



if (form1.p1.group.rawValue == 5) {

oSubform.rawValue = company5_logo.value.image.value;

}



Basically depending the user's choice on the drop-down list, the script makes the Image Field on the Master Page the same as the appropriate invisible static image on page 1.



Hope that makes sense and good luck!!



Regards,



Niall

Avatar

Former Community Member
Hi Niall



I'm new in LC, and I have to make a job similar this..

I have the following pdf:



form1

(Master Pages)

Page1

sfMasterDetails

txtObs

Page2

...

items

item

...



I need to test the length of txtObs of master page "Page1" to verify if it fit on the textbox... if doesn't to fit, I need to repeat the layout of the first masterpage (Page1)... all this at runtime



Do you know how do I could do this?