You may like to print this page for future reference.
This page does not want to install ScriptX. If ScriptX isnt installed we will redirect back to the application start page.
The page will be printed with custom headers and footers so we add ScriptX to the page but with only the required version on the codebase.
<object codebase="#Version=7,8,0,2" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory"> </object>
Javascript can then check if ScriptX is available and redirect to the helper page if not:
<script type="text/javascript"> function MeadCo_ScriptX_CheckInstalled() { var f = document.getElementById("factory"); if ( f==null || typeof(f)=="undefined" || f.object == null ) { window.location = "/Core/Install/RedirectInstall"; } } if ( window.addEventListener ) { window.addEventListener('load',MeadCo_ScriptX_CheckInstalled,false); } else { window.attachEvent("onload",MeadCo_ScriptX_CheckInstalled); } </script>
Basic ScriptX enables full control of the headers, footers and margins and for providing on page UI for initiating print, preview and page setup.
Some simple script controls print attributes:
<script type="text/javascript"> function MeadCo_ScriptX_Settings() { if ( MeadCo.ScriptX.Init() ) { try { MeadCo.ScriptX.Printing.header = "Basic Installation Sample"; MeadCo.ScriptX.Printing.footer = "&D&b&p of &P"; } catch (e) { alert("Warning - print setup failed: \n\n" + e); } } else { console.log("Warning : ScriptX failed to initialise in MeadCo_ScriptX_Settings(). Has install failed?"); } } </script>
The MeadCo ScriptX Javascript Helper library is also available as a Nuget package or may be downloaded from GitHub. The library provides methods to wrap often used functionality. The library functions and code above can be combined to complete the preview behaviour when the user clicks or taps the button.
<button class="btn btn-default" onclick="MeadCo_ScriptX_Settings(); MeadCo.ScriptX.PrintPage(true); return false;">Print ...</button>
All of the above can be generated for you by the MeadCo ScriptX Helpers for ASP.NET MVC package:
@ClientPrinting.GetHtml( Url.Action("RedirectInstall"), ClientPrinting.ValidationAction.Redirect, ClientPrinting.ScriptXHtmlPrintProcessors.Default, new PrintSettings { Header = "Basic Installation Sample", Footer = "&D&b&p of &P" })