Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

objects whose presences are toggled with javascript not printing

Avatar

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

Avatar

Correct answer by
Former Community Member

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

Avatar

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

Avatar

Level 3

Sent.

Thank you for taking the time to help me.

Avatar

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

Avatar

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..

Avatar

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?

Avatar

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

Avatar

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?

Avatar

Former Community Member

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

Avatar

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.

Avatar

Former Community Member

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

Paul

Avatar

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

Avatar

Correct answer by
Former Community Member

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

Avatar

Level 3

Paul,

     Sent, thanks again.

Brandon

Avatar

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
The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----