Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

objects whose presences are toggled with javascript not printing

BCangelosi
Level 3
Level 3

Here is what I am trying to do:

I have a subform with objects ( multiple 3 column tables, each with a checkbox followed by two text fields ) that I want to be on screen, but only print when said checkbox is "checked"

Here is what I have tried:

The subform is set to flowed so that the objects will group together on the printed form, there are approximately 35 of these mini-tables

I have tried to set the presence of each "table" to visible (screen) in the object palette and then set a change javascript in the checkbox to "object".presence = "visible" ;

this method makes the tables always visible on screen, but they do not print out even when checked.

I have tried to wrap each table in a subform and use the above method with the same results

I have tried to set each tables object palette presence to visible and use a script for initialize : "object".relevant = "-print" ; and the checkbox in each table set to change "object".presence = "visibe" ;

Same results as above, nothing prints

I have tried to set object relevance to "+print" and then after checking the checkbox in each table, the table disappears. HOWEVER it then prints. This is the closest I've come to what I want to do, but I need the table to stay after it is checked.

So. What's the key to this one?

1 Accepted Solution
pguerett
Correct answer by
Level 10
Level 10

It says the doc cannot be found or I do not have access to it.

Can you email it to LiveCyle8@gmail.com instead?

Paul

View solution in original post

15 Replies
Srini_Dhulipall
Level 10
Level 10

It looks like you have used most of the properties that are needed to achieve it.. If you can post the form to LiveCycle9@gmail.com I can see what may be missing..

Please mention where the issue is in the form..

Thanks

Srini

BCangelosi
Level 3
Level 3

Sent.

Thank you for taking the time to help me.

Srini_Dhulipall
Level 10
Level 10

Here is the corrected form..

https://acrobat.com/#d=ewLmri7On6YjYP7HDuvdiA

I have placed the scripting for two different ways to achieve it.. Check the prePrint and postPrint event scripts on the Print button. You can use which ever suits to your requirement.

Another observation..

   Instead of having 3 subforms and inside a table with 3 columns each.. Why can't you add a single table with 9 columns. Adding too many subforms and tables will impact the performance of the form and maintenance also will be difficult.

Thanks

Srini

BCangelosi
Level 3
Level 3

the subforms were only added during troubleshooting while trying to get the scripts to work. 1 table with 9 columns wouldn't group correctly.

the subforms will be unwrapped. But I am still unclear as to which of the scripts constitutes method 1 and method 2 and the function of either. I have to know as I will be needing to make things visible/hidden on print command later in the form, and probably other forms in the future.

Also, using this method, the tables do not hide themselves on print command. They merely go invisible (take up the space still, just can't see them). That defeats the whole purpose of going through the trouble of hiding unecessary tables from the print job as it uses the same amount of space, and looks awkward.

I want the "checked" tables to remain visible AND pull together, eliminating both unneeded text and wasted (dead) space. With the subform set to flowed this should be happening. As it is, with all 35+ tables, the couple that are selected to remain visible will be all over the page..

BCangelosi
Level 3
Level 3

Perhaps I'm overcomplicating this.

I guess what I really need to know is, how do I toggle an object from visible to visible (screen only) based on a user selection?

Srini_Dhulipall
Level 10
Level 10

If you want to toggle between, the Visible (Screen Only) and Visible (Print Only)..

   
Visible (Screen Only)
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell1.presence = "visible";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell1.relevant ="-print";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell2.presence = "visible";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell2.relevant ="-print";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell3.presence = "visible";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell3.relevant ="-print";
Visible (Print Only)

form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell1.presence = "visible";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell1.relevant ="+print";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell2.presence = "visible";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell2.relevant ="+print";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell3.presence = "visible";
form1.LabRequest.Diagnosis.T1.Table1.Row1.Cell3.relevant ="+print";
And set your form to Dynamic XML File..
     1) Goto File menu -> Form Properties and select Defaults tab. Change the Default Render Format as Dynamic XML form
     2) Select the Preview Tab. Set the Preview type as "Interactive Form" and Preview Adobe XML form as Dynamic XML form
     3) Finally while saving the PDF select Save As Type as "Adobe Dynamic XML Form".
Thanks
Srini
BCangelosi
Level 3
Level 3

Here is an update:

I have realized that to accomplish what I want, all I would really need to do is leave all objects as visible (in object palette) but then toggle their visiblity in the preprint event on the print button.

I have written the following script to accomplish this:

Javascript code under the preprint event of the print button

if  (form1.LabRequest.Diagnosis.T1.R1.C1.rawValue == 0 ){

form1.LabRequest.Diagnosis.T1.presence = "hidden"

endif ;

This seems to work perfectly for the first object (of which there are 33). However it doesn't work for any of the subsequent objects, using the same script as above with the same event, the only different being the name of the object.

The object will remain on screen whether the tables checkbox is selected or not. At print, if the object is NOT selected, the object will disappear and all remaining objects move to the next open space. However, as I said, it is currenlty ONLY functioning with the first object.

Is there perhaps something I need to place in between each set of the above code to make it work for all 33 objects in my subform?

pguerett
Level 10
Level 10

It is hard to tell why th eother objects do not work without seeing the code. Do you get any errors in the java console?

You might find it easier to change the presence of the entire table (if that is what you are trying to accomplish). Child objects of a parent container will inherit the settings from the parent so if all 33 objects are under a common container a single statement will do the trick.

Paul

BCangelosi
Level 3
Level 3

Srini,

     BTW I wanted to thank you for pointing me in the direction of preprint and postprint events. It was an option I had never used before, and seems to be where the answer to this problem lay.

Paul,

     Thank you for assisting. Javascript console reveals no errors in the code. In my code, T1 represents the entire table, where C1 represents the checkbox within the table. When the value of C1 is 1, it should (and does) make T1 (table 1) remain visible, whereas value 0 renders T1 (table 1) hidden (at the preprint event, as intended)

     So am I not changing the presence of the entire table by doing this?

I can send you copy of the partially functioning form if you wish to view it.

Again, any help you all provide is very much appreciated.

pguerett
Level 10
Level 10

Something happened to your upload ...I cannot access the file.

Paul

BCangelosi
Level 3
Level 3

There must have been an error in the upload.

Please try again using the new link.

https://acrobat.com/#d=2JP-FjYRgdkF8z5ee08pWw

Thank you.

Brandon

pguerett
Correct answer by
Level 10
Level 10

It says the doc cannot be found or I do not have access to it.

Can you email it to LiveCyle8@gmail.com instead?

Paul

View solution in original post

BCangelosi
Level 3
Level 3

Paul,

     Sent, thanks again.

Brandon

BCangelosi
Level 3
Level 3

Paul, thank you so much.

For anyone that may not know (script newbies like myself):

In javascript an if statement has an expression that resolves to true or false then if there are multiple staements to execute they are surrounded by { }. There is no endif. So an if statement shoudl be like this:
if (boolean expression) {
   do this part if true
} else {
   do this part if false
}
The else is optional and it is the } that acts as the endif.
Thanks to all who tried to help. This just brought my scripting knowledge to a whole new level.
Brandon