Recommendations for some common issues
This walk-through illustrates taking a classic document that has a controlled print experience and works only in Internet Explorer and making it work with ScriptX.Services in any browser on any platform using the minimum amount of development effort and making as few changes as possible (though more changes might be desirable).
Previously : Stage 7 - WaitForSpoolingComplete
How to determine if ScriptX.Services or ScriptX.Addon is in use.
In general it should not be necessary to determine which is in use, especially if the MeadCoScriptXJS Library is in use as its methods do the necessary checking for you. However it does also provide the.
IsServices()
function.
For example, when ScriptX.Services is in use it might be appropriate to dig into the implementation for more information:
if (MeadCo.ScriptX.IsServices()) {
// ScriptX.Services v2.9.0 or later is required.
MeadCo.ScriptX.Print.serviceDescriptionAsync(
function (sd) { $("#info").text(".Services version: "
+ MeadCo.ScriptX.GetComponentVersion("scriptx.services")); },
function (e) {
console.warn("serviceDescriptionAsync failed: " + e);
$("#info").text(".Services javascript library version: "
+ MeadCo.ScriptX.GetComponentVersion("scriptx.factory.services")
+ " - **please update your .Services server**");
}
);
}
else {
$("#info").text(".Addon version: " + MeadCo.ScriptX.GetComponentVersion("scriptx.factory"));
}
If MeadCoScriptXJS is not being used due to a requirement to make bare minimal changes to pre-existing code targetting ScriptX.Addon then the presence of a function can be used as a signal that ScriptX.Services is in use rather than ScriptX.Addon as the latter will not implement the function.
For example, the implementation of WaitForSpoolingComplete() for ScriptX.Services requires an additional callback argument in order to work properly with ScriptX.Services:
// If ScriptX.Services client libraries are handling printing then wait for the print to spool.
// .Addon does this automatically (within limits)
if (typeof factory.printing.PolyfillInit === "function") {
factory.printing.WaitForSpoolingComplete(-1, function () {
self.close();
});
}
else {
self.close();
}