Licensed Use :: A simple UI

Often all print attributes are set with hard-coded script, for example the page headers and footers and may be even paper size and margins.

ScriptX is also frequently used to ensure that a particular printer is used for the print out, for example that the available label printer is used even when the user has a standard laser printer as default.

There are some cases where a number of suitable printers are available and the user should be prompted to select the one of the suitable printers. ScriptX provides methods and properties that allows the available printers to be enumerated and for the attributes of the printer to be queried, for example available papersizes.

The available printers will be those with this paper size available:    

Note that the paper sizes are coded into the html of this page.
// inEnumerator
// Returns true if the (string) value is contained in
// any of the items (strings) in the COM enumeration
function inEnumerator(value, comList) {
    var e = new Enumerator(comList);
    for (;!e.atEnd();e.moveNext()){
        var x = e.item(0);
        if (x.indexOf(value) >= 0)
            return true;
    return false;
function refreshAvailablePrinters() {
    var $printers = $("#availablePrinters");
    var paperSize = $("#paperSizes").val();
    $.each(MeadCo.ScriptX.GetAvailablePrinters(), function (index, value) {
        try {
            if (inEnumerator(paperSize, MeadCo.ScriptX.Printing.printerControl(value).Forms)) {
                $printers.append($("<option/>").attr("value", value).text(value));
        } catch (e) {
            console.log("Error: " + e.message);
// do not use document.ready() as the license may still be loading
$(window).on("load",function() { 
    if (MeadCo.ScriptX.Init() && MeadCo.Licensing.IsLicensed()) {
        $("#paperSizes").change(function() {
        $("#availablePrinters").change(function() {
            try {
                // select chosen printer, then the required papersize
                with (MeadCo.ScriptX.Printing) {
                    printer = $(this).val();
                    paperSize = $("#paperSizes").val();
            } catch (e) { alert("Failed to select the printer: " + e.message); }
            console.log("Selected printer is: " + MeadCo.ScriptX.Printing.CurrentPrinter);


The sample code uses these code libraries: