Knowledgebase article Using WēPO to "push" print from a web server
WēPO is a web (ActiveX) object component that allows a web server to force a print job to print on the local browser's printer without needing to first lay out the print job as HTML data. This is called "push" printing and can be implemented as an on-screen web page print button or through web page scripting, such as javascript.
WēPO is a printer-independent web print program that is loaded with features including our Print Wizard printing engine. For further information, check out the stand-alone Print Wizard and the WēPO web page. This document covers the use of WēPO and specifically how to set it up with Internet Explorer and Netscape.
The below sections apply to using WēPO version 3.0 with Internet Explorer 5.5 or later and Netscape Navigator 7.1 or later.
Also please verify the GUID / ClassID each time to be sure you have the right one as it varies by WēPO version number.
Internet Explorer
Internet Explorer supports many helper applications and scripts, including ActiveX web page components. These are program objects that can be called from standard html code and cause an external module to load or display a component on a standard web page. These are also called OCX or web objects.By default, ActiveX components are supported by all recent versions of Internet Explorer. However, they do conform to security standards and hence are affected by your security settings inside IE.
The first time you click on a button that is for a WēPO component, IE will want to load the object from the specified web site. If your browser restricts this, check out the preferences and either make the web site a trusted site, or temporarily change this option (in Internet Explorer see the Tools : Internet Options and the Security tab).
Sample Code
Click HERE to go to a sample web page where you can then do View : Source and view the source code. Also note that there are many options that can be set or changed including the width and height, the alignment, the file to print (as a URL) and the caption. You can also add javascript or vbscript to control WēPO in different ways.
<OBJECT
classid="clsid:659D3554-54CD-46BC-B0F1-D88C4CCFD10C"
codebase="http://www.anzio.com/controls27/printwizocx.cab#version=2,7,0,0"
width=0
height=0
align=center
hspace=0
vspace=0
ID="Pwbuttonx1" VIEWASTEXT>
<param name="mainurl"
value="http://www.anzio.com/pub/printwiz-samples/features.txt">
<param name="caption" value="Print">
</OBJECT>
Check out the scripting on the example page below. With scripting you can make it print a file on load, on click of some other form item, or when your script demands it. See the Example below.
Netscape
Netscape is not a Microsoft product and in the past has not supported ActiveX components. However, with the release of version 7.1 of Netscape Navigator, support for the Windows Media Player ActiveX component was added.
For WēPO we can take advantage of this feature and actually get it to work with very little effort. And since you have to specifically permit each ActiveX to run, it remains secure. Here is what is involved in doing this:
Set the activex.js white list to permit the classid for WēPO
This is found usually in the following directory C:\Program Files\Netscape\Netscape\defaults\Pref
You will need to add the following line to the file
pref("capability.policy.default.ClassID.CID659D3554-54CD-46BC-B0F1-D88C4CCFD10C", "AllAccess");
(all as one line) right below the other entries there. Note that this makes the ClassID completely trusted. You can try setting up a trusted policy instead by adding the following (this does not always work, depending on your security settings):
user_pref("capability.policy.policynames", "trustable");
user_pref("capability.policy.trustable.sites", "http://www.anzio.com");
user_pref("capability.policy.trustable.ClassID.CID659D3554-54CD-46BC-B0F1-D88C4CCFD10C",
"AllAccess");
Adjust your web page to hide the component and force the "print"
From within a javascript function, you can force a button or other form component to print, as in the Example below (we use a manual button here). Apparently there is not a concept of a "click" event for an object, so you have to build one.
Restart Netscape after any changes to the activex.js
Any changes to activex.js will not take affect until Netscape is brought down and brought back up.
Note that any future updates to Netscape may overwrite this file, so be sure to back it up.
Example
The example below simply display a user-defined button and includes some javascript demonstrating how to cause a "print" action to occur.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
<TITLE>ActiveX test</TITLE>
</HEAD>
<BODY OnLoad="javascript:buttonhide();">
<div>Hi World</div>
<OBJECT
classid="clsid:659D3554-54CD-46BC-B0F1-D88C4CCFD10C"
codebase="http://www.anzio.com/controls27/printwizocx.cab#version=2,7,0,0"
width=0
height=0
align=center
hspace=0
vspace=0
ID="Pwbuttonx1" VIEWASTEXT>
<param name="mainurl"
value="http://www.anzio.com/pub/printwiz-samples/features.txt">
<param name="caption" value="Print">
</OBJECT>
<input type=button value="my print" OnClick="javascript:buttonclick();">
<script language=javascript>
<!--
function click(){
var print;
alert('Going to change the caption');
document.Pwbuttonx1.caption='Wow!!!';
print = confirm('Going to print the sample without touching the button!!!');
if (print)document.Pwbuttonx1.Click();
document.Pwbuttonx1.caption='Double Wow!!!';
alert('Going to make it disappear!');
document.Pwbuttonx1.Visible=false;
alert('Going to make it reappear!');
document.Pwbuttonx1.Visible=true;
}
function buttonclick(){
document.Pwbuttonx1.Click();
}
function buttonhide(){
document.Pwbuttonx1.visible=false;
}
//-->
</script>
<div> </div>
<a href="javascript:click();">Hello World - Click here!!!!</a>
</BODY>
</HTML>
Using WēPO Standalone
While WēPO was designed to be a web page component, the program itself is simply an ActiveX (OCX) component that can be called by other applications as well.
The example source listings above, as well as the sources to our example pages, will give you some ideas on how this ActiveX component can be incorporated into custom programs. Check out the sources to the examples found at
WēPO Examples
Full documentation for WēPO, its methods and its properties, can be found in the Print Wizard documentation (Print Wizard is the engine that drives the WēPO printing)
Print Wizard Manual
|