ScriptX.Services :: Working with current code

Moving older systems to modern browsers can be a daunting task. Moving code that provided controlled printing with ScriptX.Add-on to ScriptX.Services shouldn't be daunting.

Old code

Current code will look something like this ...

            factory.printing.header = "&D";
            factory.printing.footer = "";
            factory.printing.Print(false);
        

Or may be something like this ...

For example (free/basic usage):

<!-- MeadCo ScriptX -->
<object id="factory" style="display:none"
  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="http://[your path here]/smsx.cab#Version=8,0,0,56">
</object>
<script src="/scripts/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="/scripts/meadco-scriptx-1.10.1.js" type="text/javascript"></script>
<script type="text/javascript">
   $(window).on('load', function () {
     if (MeadCo.ScriptX.Init()) {
       MeadCo.ScriptX.Printing.header = 
          "MeadCo's ScriptX&b:&p of &P:&bBasic Printing Sample";
       MeadCo.ScriptX.Printing.footer = 
          "The de facto standard for advanced web-based printing";
       MeadCo.ScriptX.Printing.orientation = "landscape";
       $("#btnprint").click(function() { 
            MeadCo.ScriptX.PrintPage(false);
       });
     }      
   });
</script>

The easiest solution is to move all browsers to using ScriptX.Services. In this case, an additional javascript module is included. This module implements the API available from ScriptX.Add-on but translates the calls to the ScriptX.Services API.

Changes in licensing

A license for the ScriptX.Services server will be required. The exact form of the license depends upon the service implementation:

Supporting old and new browsers

If you can get your HTML to work with both Internet Explorer 11 and evergreen/modern browsers then you can use your current ScriptX code unchanged. Include the ScriptX.Services libraries on the page and they will quietly do nothing when ScriptX.Add-on is available. The result is users with old browsers will be able to print to a printer connected to their workstation, users of modern browsers will be able to print to printers available to the ScriptX.Services server which may be ScriptX.Services for Windows PC on their workstation.

Making it work

  touching either button will return a PDF document of this page.

To make the old code work with Script.Services and bring controlled print output to any browser just requires a few javascript files are added along with the details on how to connect to the server.

The MeadCo ScriptX.Services modules are available for download from  MeadCo ScriptX.Services print client modules .

To support old code, the following libraries are required:

<script src="/scripts/jquery-3.1.1.js"></script>
<script src="/scripts/meadco-core.js"></script>
<script src="/scripts/meadco-scriptxprint.js"></script>
<script src="/scripts/meadco-scriptxprinthtml.js"></script>
<script src="/scripts/meadco-scriptxfactory.js"></script>
<script src="/scripts/meadco-scriptxprintlicensing.js"></script>
<script src="/scripts/meadco-secmgr.js"></script>

These can be used on the page as follows:

            <!-- no add-on -->
            <!-- latest version of library -->
            <script src="/scripts/jquery-3.1.1.min.js" type="text/javascript"></script>
            <script src="/scripts/meadco-scriptx-1.10.1.js" type="text/javascript"></script>
            <!-- Add ScriptX.Services libraries (combined in workflow) -->
            <script data-meadco-server="//scriptxservices.meadroid.com" 
                    data-meadco-license="xxx-xxx-xxxxxxx-xxx" 
                    src="/scripts/meadco-scriptxservices.min.js"></script>
        

Note that the server and subscription identifier are included as attributes on the <script /> tag and so there is no reason to call MeadCo.ScriptX.Print.HTML.connect(). With this in place the <object /> tags required for the ScriptX add-on (including MeadCo License Manager) can be replaced with the <script /> tags and code will `just work`...

            <!-- code as it was before 'just works' -->
            <script type="text/javascript">
               $(window).on('load', function () {
                 if (MeadCo.ScriptX.Init()) {
                   MeadCo.ScriptX.Printing.header = 
                      "MeadCo's ScriptX&b:&p of &P:&bBasic Printing Sample";
                   MeadCo.ScriptX.Printing.footer = 
                      "The de facto standard for advanced web-based printing";
                   MeadCo.ScriptX.Printing.orientation = "landscape";
                   $("#btnprint").click(function() { 
                        MeadCo.ScriptX.PrintPage(false);
                   });
                 }      
               });
            </script>
        

Or, this works too ..

            <!-- no add-on -->
            <script src="/scripts/jquery-3.1.1.min.js" type="text/javascript"></script>
 
            <!-- Add ScriptX.Print libraries -->
            <script data-meadco-server="//scriptxservices.meadroid.com" 
                    data-meadco-license="xxx-xxx-xxxxxxx-xxx" 
                    src="/scripts/meadco-scriptxservices.min.js"></script>

            <script type="text/javascript">
               $(window).on('load', function () {
                   $("#btnprint").click(function() { 
                    factory.printing.header = "MeadCo's ScriptX.Print &b:&p of &P:&bCompatibility Sample";
                    factory.printing.footer = "The de facto standard for advanced web-based printing";
                    factory.printing.portrait = false;
                    factory.printing.Print(false);
                   });
                 }      
               });
            </script>