Server-side Printing with ScriptX

An Active Server Page (classic ASP or ASP.NET) may handle an HTTP GET or POST request and print a report (a different HTML page) as part of some server-side application logic. In this case, the print-out will take place on the server side and will go to a printer which is physically attached or networked to the server. The browsing user who originated the HTTP request may not ever see the printed output nor know that printing has taken place.

To print, the configuration parameters of the ScriptX Printing object may be used to set properties such as the printer to be used and headers and footers. To perform the print, the PrintHTML method is used, for example:

<%
 ' Apply licensing - the license must already be installed.
 set secmgr = CreateObject("MeadCo.SecMgr")
 secmgr.Apply "","{XXXX-XXXX-XXXX-XX}",X

 ' the object is dynamically created and destroyed
 set factory = CreateObject("ScriptX.Factory")
 factory.printing.header = "Report printed on the server"
 factory.printing.footer = "Printed on &D"
 factory.printing.PrintHTML "http://localhost/order.asp?number=" 
    & Request.Form("number")

 ' After use, shut down the object to ensure that resources
 ' are released in a timely manner
 factory.ShutDown
 set factory = nothing
%>

 

Session Context

Important: HTML files printed by PrintHTML calls on the server-side are download and printed in a separate process which is absolutely unrelated to the current user's ASP/ASP.NET session context, including any authentication that has occurred by the remote user, either through an authentication dialogue or automatic authentication through, for example, NTLM. If the page to be printed is secured in some way, it must be accessible by the separate process without any user intervention - this may require that automatic authentication is enabled. In the above example, http://localhost/based URLs are printed so technically this is still the same HTTP server, but in fact any URL may be used. The only way to pass any contextual information is via the querypart of the URL itself (the strings that follows the question mark).

Internet Explorer Enhanced Security Configuration

Please also note when using Windows Server 2003 and later that Internet Explorer Enhanced Security Configuration may block access to pages you are intending to print, you must ensure that IE ESC is configured appropriately.

 

::> Software and Licence Installation