Inline UI for installing ScriptX

You may like to print this page for future reference.

CSS styling will hide this UI from the print ...

This page contains ScriptX print logic. If ScriptX isnt installed we will redirect to the installation helper page which will navigate back to here when installation is sucessful.

This page is very similar to those used in the sample illustrating use of an intermediate page. The technique here is fine for a large number of situations but if you are wishing to provide informative UI then that will necessitate mixing print and help content which may not be desirable and the intermediate page may be more appropriate.

The page will be printed with custom headers and footers so we add ScriptX to the page but with only the required version on the codebase.

<object codebase="#Version=8,3,0,4" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory">
</object>

Javascript can then check if ScriptX is available and redirect to the helper page if not:

<script type="text/javascript">

function MeadCo_ScriptX_CheckInstalled() {
var f = document.getElementById("factory");
if ( f==null || typeof(f)=="undefined" || f.object == null ) {
    window.location = "/Core/Install/RedirectInstall";
}
}
if ( window.addEventListener ) { 
    window.addEventListener('load',MeadCo_ScriptX_CheckInstalled,false); 
} else { 
    window.attachEvent("onload",MeadCo_ScriptX_CheckInstalled); 
}
</script>

Using basic features of ScriptX

Basic ScriptX enables full control of the headers, footers and margins and for providing on page UI for initiating print, preview and page setup.

Some simple script controls print attributes:

<script type="text/javascript">

function MeadCo_ScriptX_Settings() { 
    if ( MeadCo.ScriptX.Init() ) { 
        try {
            MeadCo.ScriptX.Printing.header = "Basic Installation Sample";
            MeadCo.ScriptX.Printing.footer = "&D&b&p of &P";
        } catch (e) { alert("Warning - print setup failed: \n\n" + e.message); }
    } 
    else {
        console.log("Warning : ScriptX failed to initialise in MeadCo_ScriptX_Settings(). Has install failed?"); 
    }
}
</script>

The MeadCo ScriptX Javascript Helper library is also available as a Nuget package or may be downloaded from GitHub. The library provides methods to wrap often used functionality. The library functions and code above can be combined to complete the preview behaviour when the user clicks or taps the button.

<button class="btn btn-default" onclick="MeadCo_ScriptX_Settings(); MeadCo.ScriptX.PrintPage(true); return false;">Print ...</button>

Tip

All of the above can be generated for you by the MeadCo ScriptX Helpers for ASP.NET MVC package:

@ClientPrinting.GetHtml("",
    ClientPrinting.ValidationAction.Redirect,
    ClientPrinting.ScriptXHtmlPrintProcessors.Default,
    new PrintSettings
    {
        Header = "Basic Installation Sample",
        Footer = "&D&b&p of &P"
    })