Chapter 15

Imaging and Portable Document Controls


CONTENTS

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.

Using ActiveX Imaging Controls

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.

Portable Document Format 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:

Acrobat Control for ActiveX

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.

Source

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

Properties

Table 15.1 summarizes all of the properties available in the Acrobat Control for ActiveX.

Table 15.1  Properties of the Acrobat Control for ActiveX

PropertyDescription
SRCSpecifies the URL for the PDF file to be downloaded and rendered. Relative or absolute URLs may be used.

Methods

The only methods available in the Acrobat Control allow for printing and displaying the control's "About" box.

Table 15.2  Methods of the Acrobat Control for ActiveX

MethodDescription
PrintInvokes the Acrobat print dialog to allow users to print the PDF document.
AboutBoxInvokes the Acrobat Control's "About" box.

Examples

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">

Tumbleweed Software Envoy Control for ActiveX

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.

Source

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

Properties

The properties of the Tumbleweed Software Envoy Control for ActiveX are shown in Table 15.3.

Table 15.3  Properties for the Tumbleweed Software Envoy Control for ActiveX

PropertyDescription
CurrentPageThe page of the Envoy document being displayed
CurrentToolThe current mouse tool
DocumentNameThe file name of the current document
GreekPointSizeThe point size below which to greek text
RightClickMenuStateBoolean, True to enable pop-up menu
ScrollBoolean, True if scrollbars are displayed
SelectionStyleUsed to enable text and graphics selection
ToolbarBoolean, True if the toolbar is displayed
ViewStyleSelects between normal and thumbnail viewing
ViewZoomCurrent zoom level

Methods

The methods of the Tumbleweed Software Envoy Control for ActiveX are shown in Table 15.4.

Table 15.4  Methods for the Tumbleweed Software Envoy Control for ActiveX

MethodDescription
AboutBoxDisplays About box
CommandExecuteExecutes Envoy Control command
FindTextStarts a text search
GetDocumentFirstVisiblePageReturns page number of first visible page
GetDocumentInfoRetrieves document information
GetDocumentLastVisiblePageReturns page number of last visible page
GetDocumentPageCount()Returns number of pages in current document
GetSelectedTextCopies selected text to a string
GetTotalHitCountReturns the number of hits of a search
IsCommandCheckedChecks whether a predefined command is checked in the control
IsCommandEnabledChecks whether a predefined command is enabled in the control
OpenFileOpens local Envoy document
PrintPagePrints page(s) of the current document
RefreshRefreshes 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.

Table 15.5  Command Number Argument to the Envoy Control CommandExecute Method

Command Number
Description
0
Null command
1
Queries and opens local Envoy document
2
Closes current document
3
Calls standard print dialog to print all or part of document
4
Switches to the selection tool
5
Switches to the scroll tool
6
Switches to the zoom-in tool
7
Switches to the zoom-out tool
8
Fits page width to the width of the control
9
Fits page height to the height of the control
10
Fits entire page into the control
11
Begins text search
12
Finds next
13
Finds previous
14
Brings up Goto Page dialog
15
Goes to first page
16
Goes to last page
17
Goes to previous page
18
Goes to next page
19
Copies selection to clipboard
20
Goes to bookmark
21
Goes to previous view
22
Goes to next view
23
Clears current selection

Example

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

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.

Sax Canvas Control for ActiveX

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.

Source

Vendor Information:

Sax Software Corporation
http://www.saxsoft.com
950 Patterson Street
Eugene, OR 97401 USA
(541) 344-2235
(541) 344-2459 (fax)

Properties of the Sax Canvas Control for ActiveX

Table 15.6 summarizes all of the properties available in the Sax Canvas Control for ActiveX.

Table 15.6  Properties of the Sax Canvas Control for ActiveX

PropertyDescription
Back ColorSets the background color
Border ColorSets the border color
Border WidthSets the border width
Code BaseSets the location of page to download control
Current XSets the current X coordinate
Current YSets the current Y coordinate
Fill ColorSets the fill color
Fill StyleSets the fill style
FontSets the font
Fore ColorSets the fore color
HeightSets the height of the frame
IDSets the ID of the control (SaxCanvas1)
LeftSets the left position of the canvas
TopSets the top position of the frame
VisibleSets the canvas to visible
WidthSets the width of the canvas

Figure 15.3 : Sax Canvas Control for ActiveX

Methods of the Sax Canvas Control for ActiveX

Table 15.7 contains the Methods of the Sax Canvas Control for ActiveX.

Table 15.7  Methods of the Sax Canvas Control for ActiveX

MethodDescription
AboutBoxInvokes the Sax about box
ClearClears the canvas

Events of the Sax Canvas Control for ActiveX

Table 15.8 summarizes the Events of the Sax Canvas Control for ActiveX.

Table 15.8  Events of the Sax Canvas Control for ActiveX Events Actions

Click Performs action upon mouse click
DblClickPerforms actions upon mouse double-click
MouseDownPerforms actions upon moving the mouse down
MouseUpPerforms actions upon moving the mouse up
MouseMovePerforms actions upon moving the mouse over the control.

Example

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>