Expand my Community achievements bar.

Printing subforms

Avatar

Level 4
Hi,



I'm trying to capture which subforms I currently have visible, so that I can keep them visible after printing.



My current aim is to be able to hit the print button, have every form printed out and then for only the forms that were visible to be visible after the print.



I can make them visible and hidden in the pre and post print events, but how do I record which forms were open, so that they stay open later on?



Many thanks,



Tom
3 Replies

Avatar

Level 4
Is it possible to create an event in the script?



I can easily track which form is open, and then if it was possible put in something like:



CreateEvent.postPrint(form1.subform.presence="visible")

Avatar

Level 4
Right. I came up with a messy solution!



I have a variable with a prePrint() and postPrint() function (bad practise to copy names from elsewhere but never mind, was annoyed!).



There is a var in the printing variable called "visiblePage".



The prePrint() is called in the print button, just before the print command is sent via xfa.host.print and looks at every subform, checking if their presence is visible and if it is setting visiblePage to the name of that form.



Then I run my prePrint event on each form which makes each one visible.



Then I print.



Then I run my postPrint event which makes every form hidden again.



Then I call my postPrint() function, which looks at visiblePage and runs a switch statement turning whichever page was visible before the print, back to visible again.



Told you it was messy.



Tom

Avatar

Level 4
Oh, the reason that the prePrint() is called when the button is pressed as opposed to in the form's prePrint is that it was running my function after it had made all the other forms visible, so was only recording the last form as visible.



Does anyone know in what order the prePrint events are called? I would have assumed they were from the first form down to the lowest level in the hierarchy, but that didn't happen for me.