ActiveX imaging and portable document controls can change the way you display information and graphics on your Web pages. ActiveX imaging and portable document controls enable you to build Web pages that contain graphics that act and react with clear and sharp images, and documents and forms that maintain their original formatting and layout. Many different companies have created ActiveX controls that permit viewing of their imaging and document formatting over the Web. Several of these imaging and portable document controls are discussed here.
There are many different ActiveX imaging controls on the market with new ones being released daily. ActiveX imaging controls developed by third-party software companies can help you to display and manipulate images created in file formats that are not usually recognized by HTML (.gif or .jpg). This chapter takes a look at several of these controls, describing control properties, actions, and events. Additional information and a complete list of ActiveX controls may be found on Microsoft's Web site at http://www.microsoft.com/activex/controls.
Many of the documents used daily, such as expense reports, purchase requisitions, and most importantly, vacation requests, contain a combination of rich text, graphics and specific formatting. Unfortunately, many of these documents lose their luster when they are converted into HTML and placed on a Web page. To solve this problem, utilize the Portable Document Format. By generating a code that preserves all of the original formatting information of a document, the portable document format can ensure that all of the rich text formatting and layout of a document are maintained and displayed properly. Several companies have now created ActiveX controls that allow you to display portable document formatted files directly in HTML pages.
Following the standard format, descriptions of the controls will be provided along with the properties, methods, and events. Controls discussed in this chapter incude:
Perhaps the company known best for helping you to utilize portable document formatting, Adobe Systems, Inc., now has an ActiveX control available. The Acrobat Control for ActiveX provides a mechanism to view and print complete Adobe .PDF files from directly within an HTML page. With the Acrobat Control for ActiveX, .PDF files may be both viewed and printed through Microsoft Internet Explorer 3.0. .PDF (Portable Document Format) files are created from Adobe Acrobat files, and are often used to display documents that require rich text, strict formatting, and layout control.
Vendor Information:
Adobe Systems, Inc.
http://www.adobe.com/
345 Park Avenue
San Jose, CA 95110-2704 USA
(408)536-6000
(408)537-6000 (fax)
Figure 15.1 : Acrobat Control for ActiveX
Table 15.1 summarizes all of the properties available in the Acrobat
Control for ActiveX.
Property | Description |
SRC | Specifies the URL for the PDF file to be downloaded and rendered. Relative or absolute URLs may be used. |
The only methods available in the Acrobat Control allow for printing
and displaying the control's "About" box.
Method | Description |
Invokes the Acrobat print dialog to allow users to print the PDF document. | |
AboutBox | Invokes the Acrobat Control's "About" box. |
The following HTML code will insert a PDF file directly into an HTML page.
<OBJECT CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH=423 HEIGHT=333 ID=Pdf1 CODEBASE="rdrx32b.exe#Version=1,3,0,0"> <PARAM NAME = "SRC" VALUE="../test.pdf"> </OBJECT>
The following HTML code and Visual Basic Script will add an Acrobat Print button to an HTML page.
<!-- Visual Basic Script --> <SCRIPT LANGUAGE="VBSCRIPT"> Sub BtnPrint_OnClick Pdf1.Print End Sub </SCRIPT> <!--The Print button is below--> <INPUT TYPE=submit SIZE=20 MAXLENGTH=256 NAME="BtnPrint" VALUE="Print">
Similar to the Acrobat Control, the Tumbleweed Software Envoy Control for ActiveX allows you to create and embed a customized viewer for documents in the Envoy portable document format directly in an HTML page. Through this viewer, Envoy formatted documents will maintain their original formatting even as they are viewed, printed, and zoomed in on through a Web browser. VBScripts attached to HTML forms buttons may be used to provide interaction, such as the showing and hiding of toolbars and navigation through the pages displayed through the control.
Vendor Information:
Tumbleweed Software
http://www.tumbleweed.com
2010 Broadway
Redwood City, CA 94063
Figure 15.2 : Tumbleweed Software Envoy Control for ActiveX
CAUTION |
The Envoy Control for ActiveX is available from Tumbleweed Software as freeware, as are its other Envoy document viewers. However, if you wish to use the control to present Envoy format documents in your HTML documents, you will need to contact Tumbleweed Software to obtain the necessary licensing information |
The properties of the Tumbleweed Software Envoy Control for ActiveX
are shown in Table 15.3.
Property | Description |
CurrentPage | The page of the Envoy document being displayed |
CurrentTool | The current mouse tool |
DocumentName | The file name of the current document |
GreekPointSize | The point size below which to greek text |
RightClickMenuState | Boolean, True to enable pop-up menu |
Scroll | Boolean, True if scrollbars are displayed |
SelectionStyle | Used to enable text and graphics selection |
Toolbar | Boolean, True if the toolbar is displayed |
ViewStyle | Selects between normal and thumbnail viewing |
ViewZoom | Current zoom level |
The methods of the Tumbleweed Software Envoy Control for ActiveX
are shown in Table 15.4.
Method | Description |
AboutBox | Displays About box |
CommandExecute | Executes Envoy Control command |
FindText | Starts a text search |
GetDocumentFirstVisiblePage | Returns page number of first visible page |
GetDocumentInfo | Retrieves document information |
GetDocumentLastVisiblePage | Returns page number of last visible page |
GetDocumentPageCount() | Returns number of pages in current document |
GetSelectedText | Copies selected text to a string |
GetTotalHitCount | Returns the number of hits of a search |
IsCommandChecked | Checks whether a predefined command is checked in the control |
IsCommandEnabled | Checks whether a predefined command is enabled in the control |
OpenFile | Opens local Envoy document |
PrintPage | Prints page(s) of the current document |
Refresh | Refreshes the screen |
Many of the functions of the Envoy Control for ActiveX are accessed
through the CommandExecute(command_number) method.
These functions are accessed through the use of the appropriate
command number. Table 15.5 shows some of these command numbers,
along with a description of what they do.
Description | |
Null command | |
Queries and opens local Envoy document | |
Closes current document | |
Calls standard print dialog to print all or part of document | |
Switches to the selection tool | |
Switches to the scroll tool | |
Switches to the zoom-in tool | |
Switches to the zoom-out tool | |
Fits page width to the width of the control | |
Fits page height to the height of the control | |
Fits entire page into the control | |
Begins text search | |
Finds next | |
Finds previous | |
Brings up Goto Page dialog | |
Goes to first page | |
Goes to last page | |
Goes to previous page | |
Goes to next page | |
Copies selection to clipboard | |
Goes to bookmark | |
Goes to previous view | |
Goes to next view | |
Clears current selection |
Listing 15.1, based on one of the examples available through the Tumbleweed site at http://www.tumbleweed.com/eax.htm, shows how to use HTML forms buttons and VBScript to construct a custom user interface for the Envoy Control for ActiveX.
Listing 15.1 Example.html-Create Your Own Interface with HTML
forms and VBScript
<HTML> <HEAD> <TITLE>Tumbleweed Envoy Control For ActiveX Example</TITLE> <SCRIPT LANGUAGE="VBScript" > <!-- Hide script from incompatible browsers... Sub BtnOpen_onClick EnvoyControl.CommandExecute 1 'File Query and Open EnvoyControl.CommandExecute 8 'Fit Page to Width End Sub Sub BtnTool_onClick If EnvoyControl.Toolbar = TRUE Then EnvoyControl.Toolbar = FALSE BtnTool.Value="Show Toolbar" Else EnvoyControl.Toolbar = TRUE BtnTool.Value = "Hide Toolbar" End If End Sub Sub BtnScroll_onCLick If EnvoyControl.Scroll Then EnvoyControl.Scroll = False BtnScroll.Value = "Show Scrollbar" Else EnvoyControl.Scroll = True BtnScroll.Value = "Hide Scrollbar" End If End Sub Sub BtnNextPage_onClick EnvoyControl.CommandExecute 18 'Goto Next Page EnvoyControl.CommandExecute 8 'Fit Page to Width End Sub Sub BtnPrevPage_onClick EnvoyControl.CommandExecute 17 'Goto Previous Page EnvoyControl.CommandExecute 8 'Fit Page to Width End Sub Sub BtnGotoPage_onClick EnvoyControl.CurrentPage = EditPageNum.Value - 1 EnvoyControl.CommandExecute 8 'Fit Page to Width End Sub Sub EnvoyControl_HyperCommandClick(Processor,Command) If Processor = "External Link" Then If Right(Command,4) = ".evy" Then EnvoyControl.OpenFile Command Else Location.Href = Command End If End If End Sub Sub EnvoyControl_ProgressChange(Percent,Status_String) Status = StatusString End Sub --> </SCRIPT> </HEAD> <BODY BGCOLOR=#FFFFFF> <CENTER> <H1>Tumbleweed Envoy Control For ActiveX Example</H1> <HR> <OBJECT CLASSID="CLSID:5220cb21-c88d-11cf-b347-00aa00a28331"> <PARAM NAME="LPKPath" VALUE="evyactx.lpk"> </OBJECT> <INPUT TYPE=BUTTON VALUE="Open Local File" NAME="BtnOpen"> <INPUT TYPE=BUTTON VALUE="Hide Toolbar" NAME="BtnTool"> <INPUT TYPE=BUTTON VALUE="Hide Scrollbar" NAME="BtnScroll"> <HR> <OBJECT ID=EnvoyControl CLASSID="clsid:92B54588-AE4A-11CF-A1DD-004095E18035" CODEBASE="http://www.tumbleweed.com/ftp/evyactx.cab#version=1,0,0,141" HEIGHT=450 WIDTH=100%> <PARAM NAME="DocumentName" VALUE="document.evy"> <PARAM NAME="Toolbar" VALUE=TRUE> <PARAM NAME="Scroll" VALUE=TRUE> </OBJECT> <HR> <INPUT TYPE=BUTTON VALUE="Next Page" NAME="BtnNextPage"> <INPUT TYPE=BUTTON VALUE="Previous Page" NAME="BtnPrevPage"> <INPUT TYPE=BUTTON VALUE="Goto Page" NAME="BtnGotoPage"> <INPUT TYPE=TEXT VALUE="1" NAME="EditPageNum" SIZE=5> </CENTER> </BODY> </HTML>
Remember, to use the Envoy Control for ActiveX to display Envoy documents in your own Web pages, you will need to have the proper licensing of the control. You should note the following from the example listing:
Illustration controls work with you to provide real-time, interactive
drawing capabilities on your HTML page. The illustration control
provides an interactive canvas, and works with VBScript or JScript
drawing commands to interact with the user.
Creating Graphics Like the Pros-Almost |
Creating great graphics used to be the secret of the design schools, and the tricks of the trade were practiced in the loft spaces of advertising agencies and design firms. But access to the Internet-along with advances in graphics software-began a proliferation of graphics tools that were so easy to use that even non-designers could produce "professional" looking graphics. The Internet has provided a new breed of graphics developers-anyone who can download a shareware program and perform simple Windows-based commands-access to hundreds of thousands of images, and the tools to change their shape, color, and texture. Now for the professional graphics designers out there, there is no need to worry. All the easy-to-use tools in the world cannot replace true technical training. But the realm of graphics design has been opened, and users of all levels will be layering images and changing colors. For more information on the graphics tools that the pros use, search for graphic tools in your favorite search engine. |
The Sax Canvas Control for ActiveX from Sax Software, Inc. allows you to use VBScript or JScript drawing instructions to draw directly from within the browser. Script commands are executed and the canvas is updated in a seamless, dynamic fashion.
Vendor Information:
Sax Software Corporation
http://www.saxsoft.com
950 Patterson Street
Eugene, OR 97401 USA
(541) 344-2235
(541) 344-2459 (fax)
Table 15.6 summarizes all of the properties available in the Sax
Canvas Control for ActiveX.
Property | Description |
Back Color | Sets the background color |
Border Color | Sets the border color |
Border Width | Sets the border width |
Code Base | Sets the location of page to download control |
Current X | Sets the current X coordinate |
Current Y | Sets the current Y coordinate |
Fill Color | Sets the fill color |
Fill Style | Sets the fill style |
Font | Sets the font |
Fore Color | Sets the fore color |
Height | Sets the height of the frame |
ID | Sets the ID of the control (SaxCanvas1) |
Left | Sets the left position of the canvas |
Top | Sets the top position of the frame |
Visible | Sets the canvas to visible |
Width | Sets the width of the canvas |
Figure 15.3 : Sax Canvas Control for ActiveX
Table 15.7 contains the Methods of the Sax Canvas Control for
ActiveX.
Method | Description |
AboutBox | Invokes the Sax about box |
Clear | Clears the canvas |
Table 15.8 summarizes the Events of the Sax Canvas Control for
ActiveX.
Click | Performs action upon mouse click |
DblClick | Performs actions upon mouse double-click |
MouseDown | Performs actions upon moving the mouse down |
MouseUp | Performs actions upon moving the mouse up |
MouseMove | Performs actions upon moving the mouse over the control. |
The following code will insert the Sax Canvas Control, allowing you to display your VBScript and Jscript drawing instructions on an HTML page.
<OBJECT ID="SaxCanvas1" WIDTH=100 HEIGHT=61 CLASSID="CLSID:1Df67C43-AEAA-11CF-BA92-444553540000"> <PARAM NAME="_Version" VALUE="65536"> <PARAM NAME="_ExtentX" VALUE="2646"> <PARAM NAME="_ExtentY" VALUE="1623"> <PARAM NAME="_StockProps" VALUE="13"> <PARAM NAME="ForeColor" VALUE="0"> <PARAM NAME="BackColor" VALUE="16776960"> </OBJECT>
The following VBScript used in conjunction with the Sax Canvas Control lets you play an interactive game of tic tac toe. This code and more examples of using VBScript with the Sax Canvas Control may be found on the Sax Web site as previously listed.
<SCRIPT LANGUAGE="VBScript"> <!-- Sub window_onLoad() InitBoard End Sub ' Module level variables Dim Field ' Draw initial board and empty field Sub InitBoard() Field = " " ' Draw board Canvas.Clear Canvas.BorderColor = 128 Canvas.BorderWidth = 10 Canvas.MoveTo 100, 10 Canvas.LineTo 100, 290 Canvas.MoveTo 200, 10 Canvas.LineTo 200, 290 Canvas.MoveTo 10, 100 Canvas.LineTo 290, 100 Canvas.MoveTo 10, 200 Canvas.LineTo 290, 200 End Sub ' Make player's move and respond with your own Sub Canvas_MouseDown(Button, Shift, x, y) If Field = "" Then InitBoard If MakeMove("X", x \ 100, y \ 100) Then Do myX = Rnd * 300 myY = Rnd * 300 Loop Until MakeMove("O", myX \ 100, myY \ 100) End If End Sub ' Draw move and update Field variable ' Check if won, and if so, display message ' If bord full or won, clear bord Function MakeMove(Player, X, Y) ' If the board is full, start over If Instr(Field, " ") = 0 Then InitBoard ' Check to see if it's a valid move. If FieldItem(X,Y) <> " " Then MakeMove = False Exit Function End If Field = Left(Field, X + 3 * Y) + Player + Mid(Field, X + 3 * Y + 2) If Player = "X" Then Canvas.BorderWidth = 16 Canvas.BorderColor = 16711680 Canvas.MoveTo X * 100 + 30, Y * 100 + 30 Canvas.LineTo (X + 1) * 100 - 30, (Y + 1) * 100 - 30 Canvas.MoveTo (X + 1) * 100 - 30, Y * 100 + 30 Canvas.LineTo X * 100 + 30, (Y + 1) * 100 - 30 Else Canvas.BorderWidth = 20 Canvas.BorderColor = 255 Canvas.FillColor = 11206655 Canvas.FillStyle = 0 Canvas.MoveTo (X * 100) + 50, (Y * 100) + 50 Canvas.Circle 25 End If If CheckMove(X, Y) Then If Player = "X" Then MsgBox "Congratulations!", 0, "Tic-Tac-Toe" else MsgBox "I'm smarter than you...", 0, "Tic-Tac-Toe" Field = "XXXXXXXXX" ' Force new game next time End If MakeMove = True End Function ' Returns item at a certain position ("X", "O", or " ") Function FieldItem(X, Y) FieldItem = Mid(Field, 1 + X + Y * 3, 1) End Function ' Check if if all the items in a row are the same value Function CheckLine(X, Y, dX, dY, Value) If (FieldItem(X, Y) = Value) and (FieldItem(X + dX, Y + dY) = Value) and (FieldItem(X + 2 * dX, Y + 2 * dY) = Value) Then CheckLine = True else CheckLine = False End If End Function ' Check if rows at a certain position contain three in a row Function CheckMove(X, Y) CheckMove = CheckLine(0, Y, 1, 0, FieldItem(X, Y)) or CheckLine(X, 0, 0, 1, FieldItem(X, Y)) or CheckLine(0, 0, 1, 1, FieldItem(X, Y)) or CheckLine(0, 2, 1, -1, FieldItem(X, Y)) End Function --> </SCRIPT>