Install License

Using an advanced feature 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. An advanced use license enables more features. Here, the license enables selecting the paper to use.

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

Some simple script controls the required print attributes:

<script type="text/javascript">

function MeadCo_ScriptX_Settings() { 
    if ( MeadCo.ScriptX.Init() ) { 
        try {
            MeadCo.ScriptX.Printing.header = "Advanced License Sample";
            MeadCo.ScriptX.Printing.footer = "&D&b&p of &P";
            MeadCo.ScriptX.Printing.paperSize = "A5";
        } 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>

Using the licensed feature requires that MeadCo Security Manager is included on the page:

<object classid="clsid:5445BE81-B796-11D2-B931-002018654E2E" codebase="/content/bin/smsx.cab#Version=7,8,0,2" id="secmgr" >
    <param name="GUID" value="{2673ed0c-4340-4b15-a431-80a947e76481}" />
    <param name="Revision" value="0" />
    <param name="Path" value="/content/license/sxlic.mlf" />
    <param name="PerUser" value="True" />
</object>

ScriptX factory is required but without a full codebase as both Security Manager and ScriptX components are installed from the same cab.

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

A UI to use the advanced features can be implemented with a button element on the page along with scripts that validates acceptance of the licenses and adds behavior to the button:

<script type="text/javascript">

    // do not use $(function() {}) as the license may still be loading.
    $(window).on("load",function () {
        if (MeadCo.ScriptX.Init()) {
            $("#sxVersion").text(MeadCo.ScriptX.ScriptXVersion());
            if (MeadCo.Licensing.IsLicensed()) {
                $("#btn-print").click(function() {
                    MeadCo_ScriptX_Settings();
                    // license enables promptless printing
                    MeadCo.ScriptX.PrintPage(false);
                });
            } else {
                MeadCo.Licensing.ReportError();
            }
        }
    });
</script>

Tip

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 including validation that the license is available and report errors if not.