It is typical, simplest and most reliable to place the ScriptX add-on and the associated javascript in the topmost document.
However, when working with portal frameworks this may not be possible, so ScriptX must be placed within the frame/iframe element to be printed.
This sample illustrates the printing and preview of content within a single nested iframe element.