Hey JL,
Have you considered having a rule that calls the XDocument.Printout code and then changes the state of a boolean (yes-no) field in the form to true (default is false). Add two sections which are conditionally shown or hidden based on that field. In the first section, drag the button that prints the form and make the condition for the section hide when the field is true. Now, the rule behind the button, calls your XDocument.Printout and then sets the field to true which hides it. The second section has a condition that hides the form if the boolean field is false, so when it becomes true it is visible. In this section, but a button to close the form which calls the Close True code. Now you have a solution, albeit one that requires an additional manual step.
Patrick Halstead
Project Manager at Qdabra