New ASP.NET MVC Helpers for MeadCo ScriptX

Version 2.0.0 of MeadCo ScriptX Helpers for ASP.NET MVC is now available on Nuget and Github. Also available is version 2.0.0 of MeadCo.ScriptXConfigurationHandler, also on Nuget and GitHub. All code is available under the MIT Open Source License.

If you don’t know what these helpers are and how they can help then take a look at our quick introduction that uses v1.

These are the next two pieces of our ScriptX 8 puzzle. We are working towards this release with new infrastructure in place to support ease of developing new systems, maintenance of current systems and delivery the right version of ScriptX to the users Internet Explorer browser.

Version 2 of the ASP.NET MVC Helpers are source code compatible with v1 but have a significantly revised set of dependencies. The dependency tree now allows us to update any individual component without breaking others and dependencies are finer grained. In particular the configuration handler component no longer ships as part of the ScriptX binaries package but is separate.

This revision means we have de-coupled the version 2 packages from the version 1 packages; there is no automatic update path from v1 to v2 and you must uninstall v1 first, then install v2.

The v2 components are:

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

ScriptX Handlers for ASP.NET Provides helpers for generating the html objects for ScriptX and html and code for simple buttons.
Configuration handler Implements a section in the web.config file in which the available versions of ScriptX and their installers and license can be described.
MeadCo ScriptX bits for ASP.NET [Beta] Adds the .msi and .cab files to install ScriptX to the /Content folder of the application and adds a configuration element to the web.config file. These are used by the above components to provide an intallation experience to the user that is easy to understand and trust.

The above table reflects the dependencies. Installing the ASP.NET MVC Helpers will pull in the other packages. It will also pull in MeadCo ScriptX JS Library 1.1.0.

Note that the binary installers are currently v8 [Beta]. We will be rapidly iterating ScriptX 8 over the coming weeks and you may well want to avoid ScriptX 8 during this phase but would like to use the new handler and configuration code with ScriptX 7. This is entirely possible.

If you haven’t already done so, obtain the v7 installers:

  1. Download the ScriptX 7 resource kit.
  2. Install the kit. This will <strong>not</strong> install ScriptX but will copy the installer files to your machine.

Add the installers to your application:

  1. Copy the required installers into your web application – we recommend a destination of ~/Content/MeadCo.ScriptX/installers folder.
  2. Update the web.config file with the version and filenames, for example you should end up with something looking like this:

n

<meadco>
<scriptx>
<clientinstaller
filename="~/content/~/content/meadco.scriptx/installers/smsx.cab"
manualfilename="~/content/meadco.scriptx/installers/ScriptX.msi"
version="7.7.0.20" scope="machine" processor="x86"
installhelper="~/ScriptXClientPrinting/Install" />
</scriptx>
</meadco>

n

View gistfile.txt on Github

Once that is all in place, then a simple view to print a html document would be like this:

@using MeadCo.ScriptXClient

<div class="pagecontent">
  <button class="btn btn-default" id="btn-print">Print document</button>
</div>

@* Output ScriptX tags. Will use installer page if required *@
@MeadCo.ScriptXClient.ClientPrinting.GetHtml(
  clientValidationAction: ClientPrinting.ValidationAction.Redirect,
  printSettings: new PrintSettings
  {
    Header = "&w&bPage &p of &P",
    Footer = "&b&b&d",
    PageSetup = new PrintSettings.PaperSetup
    {
        Units = PrintSettings.MarginUnits.Inches,
        Margins = new PrintSettings.PrintMargins
        {
            Bottom = "0.5",
            Top = "0.5",
            Left = "0.5",
            Right = "0.5"
        }
    }
  })

 @section scripts {
   <script type="text/javascript">
        // do not use document.ready() as the license may still be loading
        $(window).load(function () {
            if (MeadCo.ScriptX.Init() && MeadCo.Licensing.IsLicensed()) {    
              $("btn-print").click(function() {
                MeadCo_ScriptX_Settings(); @* func generated by ClientPrinting. *@
                MeadCo.ScriptX.BackgroundPrintURL("@Url.Action("MyReport")",false);
              });
            }
            else {
                $("button[id^='btn-']").prop("disabled", true);
                MeadCo.Licensing.ReportError();
            }
        }
   </script>
 }
 

n

View viewandprint.cshtml on Github

Standardised web printing

with ScriptX.Services

ScriptX.Services is the only web printing software that can offer the level of control and flexibility required for consistent printing from different connected devices. We promise you’ll love it, try it now with a 60 day no obligation license.

Standardised web printing

with ScriptX.Services

ScriptX.Services is the only web printing software that can offer the level of control and flexibility required for consistent printing from different connected devices. We promise you’ll love it, try it now with a 60 day no obligation license.