ScriptX logotype
  • Getting started
  • Documentation
  • Samples
  • Pricing
Free Trial Downloads
  • Home
  • Getting started
  • Documentation
  • Samples
  • Pricing
Developers ›  Knowledge Bank ›  How To Guides ›  ScriptX.Add-on ›  Guide To Client-side Printing ›  Client-side Nuget Packages Reference ›  Helpers for ASP.NET MVC

Helpers for ASP.NET MVC

This package is deprecated and no longer maintained.

The Helpers for ASP.NET MVC package contains helper classes and resources to simplify the implementation of common scenarios for providing a controlled printing experience within an ASP.NET MVC application/site:

  • Installation of the ScriptX add‑on on the client PC by a sample controller and view page crafted to assist the user during the installation process with prompts and screen snips depending upon the version of Internet Explorer being used.
  • Initialising print settings such as headers, footers, margins and the printer to use.
  • Buttons to initiate printing.

Printing with Client-side ScriptX is entirely a client PC process and so the ScriptX helpers all emit HTML, javascript and client event handlers that are executed on the client PC. There is never a call back to the server (action execution).

This package is dependent upon the following packages:

  • MeadCo ScriptX - installers for web sites
    This package provides the installers for the ScriptX binaries and a custom configuration section that also allows you to specify any Advanced Printing publishing license you have purchased - or the evaluation license.
  • MeadCo ScriptX JS Simple Wrapper
    This packages provides convenient wrappers on some common ScriptX functionality. It is not dependent on any other library (such as jQuery).
  • Microsoft ASP.NET Web Optimization Framework
    ASP.NET Optimization introduces a way to bundle and optimize CSS and JavaScript files.

There are no dependencies on any particular client-side framework such as jQuery or Angular. The helpers output script in the global client-side namespace with all function names starting with ‘MeadCo_’. There are very few functions (one or two) and so there is little if any difference to wrapping the functions in a client-side namespace.

All of the server controls are provided in the namespace MeadCo.ScriptXClient:

The following controls are provided:

  • ClientPrinting
  • PrintButton
  • PrintPreviewButton

Using licensed features

Some features requires an Advanced printing publishing license.

To enable the licensed features, specify your license in the installers config section. For example, to use the evaluation license, edit the config section to include the evaluation license. The section will look like this:


    <meadco>
        <scriptx>
            <clientinstaller filename="~/content/meadco.scriptx/installers/smsx.cab"
                             version="8,3,0,4" installhelper="~/ScriptXClientPrinting/Install" />
            <license guid="{8f351de0-5990-45c3-8fd2-8037b878939f}"
                     revision="0"
                     filename="http://licenses.meadroid.com/download/{8f351de0-5990-45c3-8fd2-8037b878939f}/mlf" />
        </scriptx>
    </meadco>

Initialising printing at the client with MeadCo.ScriptX.ClientPrinting

Initialising printing at the client requires:

  • The ScriptX add‑on ‘factory’ object
  • Some javascript to set the required print parameters

The section ‘Basic printing with ScriptX’ illustrates how to do this and while not at all difficult there are tedious aspects such as neatly handling the case of the add‑on needing to be installed.

The MeadCo.ScriptX.ClientPrinting helper simplifies the coding to using an intuitive set of classes:


@ClientPrinting.GetHtml(printSettings: new PrintSettings()
{
    Footer = "Hello there from ScriptX MVC: &p of &P",
    Header = "ScriptX Demonstration page printed on: &D".
    PageSetup = new PrintSettings.PaperSetup()
    {
        Orientation = PrintSettings.Orientation.Landscape,
        Margins = new PrintSettings.PrintMargins()
        {
            Left = "1",
            Right = "1"
        }
    }
},clientValidationAction:ClientPrinting.ValidationAction.Redirect)
class MeadCo.ScriptXClient.ClientPrinting

This class provides instance and static methods GetHtml() that return the required html and scripting to declare the MeadCo ScriptX objects on the page (the MeadCo Secruty Manager object will be included if a license is described in web.config).

A view may call the static method as illustrated above. Alternatively a controller may create an instance of the class and set properties with the instance then passed to the view via one of the standard mechanisms (ViewBag, View Model etc) and then the view calls GetHtml() on the instance.

For example, a controller action may use this code before calling the view:


    ClientPrinting p = new ClientPrinting() {
        PrintSettings =
        {
            Header = "Report: &D",
            Footer = "Page &p of &P",
        }
    };

    p.PrintSettings.PageSetup = new PrintSettings.PaperSetup()
    {
        Orientation = PrintSettings.Orientation.Landscape
    };

    p.ClientValidate = ClientPrinting.ValidationAction.None;
    p.HtmlPrintProcessor = ClientPrinting.ScriptXHtmlPrintProcessors.Default;
    p.InstallHelperUrl = @Url.Action("InstallScriptX", "Home");
    ViewBag.ScriptXClient = p;

and then the view may call:


    @((ClientPrinting)ViewBag.ScriptXClient).GetHtml()


Methods Description
public static HtmlString GetHtml() Returns the HTML markup for the required objects and script to initialise the ScriptX on the client as determined from the arguments.
public HtmlString GetHtml() Returns the HTML markup for the required objects and script to initialise the ScriptX on the client as determined from the instance properties.

Properties Description Default
ValidationAction ClientValidate Specifies whether the ScriptX add‑on is to be installed if the required version isn't already installed. If the value is ‘redirect’ then if the required version is not available the user will be redirected to the installer page. ValidationAction.None - no scripted check is made that ScriptX is available. Internet Explorer will prompt to install the add‑on if it is not installed or a newer version is required.
string InstallHelperUrl The URL to redirect to when ClientValidate is ‘redirect’ and if the required version of ScriptX is not installed on the client PC The value of the installhelper attribute of the clientinstaller configuration element
ScriptXHtmlPrintProcessors HtmlPrintProcessor The HTML template to use. May be one of the values Default, Classic, IE7, IE 5, MaxiPT. This attribute specifies the value of the ScriptX templateUrl property ScriptXHtmlPrintProcessors.Default
PrintSetttings PrintSettings Describes the requires print settings such as header and footer, printer to use and orientation No settings
class PrintSettings

Describes common settings to apply to the print.

Properties Description Default
string Footer The footer text to use. See the footer reference for details. The user's IE default.
string Header The header text to use. See the header reference for details. The user's IE default.
string HeaderFooterFont A description of the font to use. The ScriptX reference for headerFooterFont gives full details. The user's IE default.
string Printer The printer to use. A publishing license is required to use this attribute. The user's default printer
PaperSetup PageSetup Describes the paper to use for the print The default for the user's default printer.
class PaperSetup

Describes the paper to use - its size, orientation and source.

Properties Description Default
Orientation Orientation The paper orientation, e.g. Orientation.Landcape The user's IE default.
string PaperSource The name of the paper source to use (e.g. "Tray 1"). A publishing license is required to use this attribute. The printer default.
string PaperSize The name of the paper size to use (e.g. "A4"). A publishing license is required to use this attribute. The printer default.
MarginUnits Units The measurement units to use for margins, e.g. MarginUnits.Inches or MarginUnits.Mm. A publishing license is required to use this attribute. The user's default printer
PrintMargins Margins The margins to apply. The user's default.
class PrintMargins

Describes the print margins to use. All margins are in the units specified in the parent PaperSetup class instance, or the users' default. Note that no margin value can be less than the printer's unprintable margin.

Attribute Description Default
string Left The left margin value in the specified units. The user's IE default.
string Top The top margin value in the specified units. The user's IE default.
string Right The right margin value in the specified units. The user's IE default.
string Bottom The bottom margin value in the specified units. The user's IE default.
Print the current page with MeadCo.ScriptXClient.PrintButton

The MeadCo.ScriptXClient.PrintButton class provides a single static method GetHtml(). The method returns the HTML for a button element that when clicked will cause the current page to be printed according to the settings defined with
MeadCo.ScriptXClient.ClientPrinting(…settings…).GetHtml().

For example:


@PrintButton.GetHtml(htmlAttributes: new { @class = "btn btn-small" })

PrintButton.GetHtml(string text = “Print”, bool prompt = true, string frame = null, object htmlAttributes=null)

Parameters Description Notes
text The button text.
prompt Whether the user should be prompted to select a printer. To use ‘false’ a publishing license is required.
frame The name of the frame to be printed.
Preview the current page or frame with MeadCoScriptX:PrintPreviewButton

The MeadCo.ScriptXClient.PrintPreviewButton class provides a single static method GetHtml(). The method returns the HTML for a button element that when clicked will cause the current page to be previewed according to the settings defined with MeadCo.ScriptXClient.ClientPrinting(…settings…).GetHtml().

For example:


@PrintPreviewButton.GetHtml(htmlAttributes: new { @class="btn btn-small"} )

PrintPreviewButton.GetHtml(string text = "Preview …", string frame = null, object htmlAttributes = null)

Parameters Description
text The button text.
frame The name of the frame to be previewed.
  • Knowledge Bank
  • 'How To' Guides
    • ScriptX.Services
      • Introduction
      • Getting started
      • Evaluate with modern code
      • Maintaining investment in current code
        • Stage 1: Adding UI
        • Stage 2: Printing with ScriptX.Services
        • Stage 3: Summary and review
        • Stage 4: Error reporting
        • Stage 5: Prompted printing
        • Stage 6: Preparing for advanced uses
        • Stage 7: WaitForSpoolingComplete
        • Stage 8: Recommendations for some common issues
      • Printing with the API
      • MeadCoScriptXJS Library
      • Installing ScriptX.Services
        • For Windows PC
        • For On Premise Devices hosted on Windows Server
        • For On Premise Devices hosted on Windows 10/11
        • Configure options For On Premise Devices
        • Cloud
      • Orchestrator
      • Debugging
      • License deployment
        • For Windows PC
        • For On Premise Devices
      • Samples
        • Configure for Windows PC
        • Configure for On Premise
        • Configure for Cloud
    • Security Manager
      • Deploying a license or revision
    • ScriptX.Add-on
      • Introduction
      • Installing ScriptX on client PCs
      • Basic printing with ScriptX
      • Advanced printing features
      • Backwards compatibility
      • How to check if ScriptX is installed
      • License deployment
      • Quick start with Visual Studio
        • ASP.NET MVC
        • ASP.NET Web Forms
      • Nuget Packages
        • MeadCoScriptXJS Library
        • Installer helpers
        • ASP.NET WebForms Controls
        • Helpers for ASP.NET MVC
      • Client-side printing samples
  • Technical Reference
    • ScriptX.Services
      • Web service API
        • Service Description
          • (GET)
        • Licensing
          • licensing (GET)
          • licensing (POST)
          • licensing/ping (GET)
        • Printer
          • settings (GET)
          • current (GET)
          • current (PUT)
          • connection (PUT)
          • connection (DELETE)
        • PrintHtml
          • settings (GET)
          • deviceinfo (GET)
          • htmlPrintDefaults (GET)
          • print (POST)
          • status (GET)
          • download (GET)
          • canceljob (PUT)
        • PrintPdf
          • print (POST)
          • status (GET)
          • download (GET)
        • PrintDirect
          • print (POST)
      • Orchestrator API
        • v1
          • GET
        • v2
          • PUT
          • GET
      • ScriptX.Services compatibility roadmap
    • Security Manager
      • How it works
      • License Expiry
      • Testing for a valid license
      • About the license file (.mlf)
        • LICENSE
        • APPLICENSE
        • TITLE
        • DOMAINS
        • DOMAIN
        • PERMISSION
      • API
        • Apply
        • License
        • result
        • validLicense
    • ScriptX.Add-on
      • factory
        • baseUrl
        • ComponentVersionString
        • IsUniqueIDAvailable
        • OnDocumentComplete
        • relativeUrl
        • ResetUniqueID
        • ScriptXVersion
        • SecurityManagerVersion
        • Shutdown
        • UniqueID
      • printing
        • AddPrinterConnection
        • BatchPrintPDF
        • BatchPrintPDFEx
        • bottomMargin
        • collate
        • copies
        • currentPrinter
        • DefaultPrinter
        • disableUI
        • duplex
        • duplex2
        • EnumJobs
        • EnumPrinters
        • footer
        • GetJobsCount
        • GetMarginMeasure
        • header
        • headerFooterFont
        • IsSpooling
        • IsTemplateSupported
        • leftMargin
        • onafterprint
        • onbeforeprint
        • onbeforeunload
        • onpagesetup
        • onuserpagesetup
        • onuserprint
        • onuserprintpreview
        • orientation
        • OwnQueue
        • pageHeight
        • PageSetup
        • pageWidth
        • paperSize
        • paperSource
        • paperSource2
        • portrait
        • Preview
        • Print
        • printBackground
        • printer
        • PrintHTML
        • PrintHTMLEx
        • PrintPDF
        • PrintSetup
        • printToFileName
        • RemovePrinterConnection
        • rightMargin
        • SetMarginMeasure
        • SetPageRange
        • SetPreviewZoom
        • SetPrintScale
        • Sleep
        • templateURL
        • topMargin
        • TotalPrintPages
        • unprintableBottom
        • unprintableLeft
        • unprintableRight
        • unprintableTop
        • WaitForSpoolingComplete
      • printerControl
        • attributes
        • Bins
        • Forms
        • isLocal
        • isNetwork
        • isShared
        • Jobs
        • location
        • name
        • Pause
        • port
        • Purge
        • Resume
        • serverName
        • shareName
        • status
      • Job
        • Delete
        • Pause
        • Restart
        • Resume
      • enhancedFormatting
        • allFooterHeight
        • allHeaderHeight
        • allPagesFooter
        • allPagesHeader
        • extraFirstFooterHeight
        • extraFirstPageFooter
        • firstFooterHeight
        • firstHeaderHeight
        • firstPageFooter
        • firstPageHeader
        • pageRange
        • printingPass
      • rawPrinting
        • printer
        • printDocument
        • printString
    • Change and history logs
    • Articles
      • v1.15.x ScriptX Client Library
      • Dialogs with ScriptX.Services
      • Accessing protected content
      • Long term servicing (LTS)
 
ScriptX logotype
Home Getting started Documentation Samples Contact us

© 2025 Mead & Co Limited.

Follow us:
LinkedIn   GitHub
X

Warning:

This ScriptX.Add-on sample can only be viewed using Internet Explorer.