ScriptX.Print :: Working with current code

Moving older systems to modern browsers can be a daunting task. Moving code that provided controlled printing with the ScriptX add-on to ScriptX.Print 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.4.0.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.Print. In this case, an additional javascript module is included. This module implements the API available from the ScriptX add-on but translates the calls to the ScriptX.Print API.

Changes in licensing

With the move to a server based system, the client no longer needs to accept a license. There is no equivalent of the MeadCo Security Manager add-on.

For our public Internet based server we have implemented CORS and therefor developers must request a subscription, even if it is free, in order for the calls from other domains to succeed. For an on premise server this will be optional.

A license for the ScriptX.Print server will be required.

Supporting old and new browsers

If you can get your HTML to work with both old (before Internet Explorer 11) and modern browsers then you can use your current ScriptX code unchanged. Include the ScriptX.Print libraries on the page and they will quietly do nothing when the 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.Print server.

Making it work

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

To make the old code work with Script.Print 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.Print modules are available for download from  Github.

To support old code, the following libraries are required:

<script src="~/Scripts/jquery-3.1.1.js"></script>
<script src="/scripts/MeadCo.ScriptX/core.js"></script>
<script src="/scripts/MeadCo.ScriptX/scriptxprint.js"></script>
<script src="/scripts/MeadCo.ScriptX/scriptxprinthtml.js"></script>
<script src="/scripts/MeadCo.ScriptX/scriptxfactory.js"></script>
<script src="/scripts/MeadCo.ScriptX/scriptxlicense.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.4.0.js" type="text/javascript"></script>
            <!-- Add ScriptX.Print libraries (combined in workflow) -->
            <script src="/scripts/MeadCo.ScriptX/meadco-scriptxprint.js"></script>
            <script data-meadco-server="htp://scriptx.print.meadroid.net" 
                    data-meadco-license="xxx-xxx-xxxxxxx-xxx" 
                    src="/scripts/meadco.scriptx/meadco-scriptxfactory.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 src="/scripts/MeadCo.ScriptX/meadco-scriptxprint.js"></script>
            <script data-meadco-server="htp://scriptx.print.meadroid.net" 
                    data-meadco-license="xxx-xxx-xxxxxxx-xxx" 
                    src="/scripts/MeadCo.ScriptX/meadco-scriptxfactory.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>