MainExamplesDocumentationRegistration  


 Info
What is ShotGraph
Why use ShotGraph
Download
How to register
FAQ


 Making images
Common principles
Palettes
OLE support
ShotGraph on 64-bit Windows
Creating animations
Trick: anti-aliased fonts
 

OLE support

Beginnig with version 1.1, ShotGraph is both OLE server and client. You can use client capabilities of ShotGraph to draw documents created by registered OLE server applications on your picture and export them to GIF format on-line. To work with these capabilities you should use CheckObject and DrawObject functions. The well known family of OLE server appications is MS Office applications: MS Word, Excel and PowerPoint.
Using ShotGraph, your scripts can easy work with documents created by these applications and build, for example, on-line preview. In the examples on this page you can see how to build preview with shrinking of MS Word document, Mydoc.doc (the text was extracted from www.w3.org).

The examples below show how to build preview of MS Word document, Mydoc.doc by three different ways.

Note: the speed of creating of required application object (MsWord in the example) can be low in this examples. And, therefore, the speed of script can be low. So, you possibly need to use some file cache solution to increase script performance.

Well, imagine we have the following MS Word document:


The preview will look like this, with shadow:

The first way (using MS Word objects)

<%@ Language=VBScript %>
<%
Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")

set word=CreateObject("Word.Application")
'Opening the document read-only
word.Documents.Open "c:\mydoc.doc",False,True
set w_doc=word.ActiveDocument

'Size of shadow
shad=4

sizex=200
sizey=200
obj.CreateImage sizex+shad,sizey+shad,256
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
'Shadow Color
obj.SetColor 2,153,153,153
obj.SetBgColor 0
obj.SetDrawColor 1
'Clearing the image area
obj.FillRect 0,0,sizex-1,sizey-1
obj.CheckObject w_doc,x,y
if x>0 then
	obj.DrawObject w_doc,"CONTENT",2,2,x*3/5,y*3/5
end if

'Drawing a bounding black rectangle
obj.CreateBrush "BS_NULL",2,""
obj.SetDrawColor 0
obj.Rectangle 1,1,sizex-2,sizey-2
obj.SetDrawColor 1
obj.Rectangle 0,0,sizex-1,sizey-1
obj.SetBgColor 0
obj.FillRect sizex,sizey+shad-1,sizex,sizey+shad

'Drawing a shadow
obj.SetBgColor 0
obj.FillRect sizex,0,sizex+shad-1,shad-1
obj.FillRect 0,sizey,shad-1,sizey+shad-1
obj.SetBgColor 2
obj.FillRect sizex,shad,sizex+shad-1,sizey+shad-1
obj.FillRect shad,sizey,sizex+shad-1,sizey+shad-1

obj.WebPalette

w_doc.Close False
word.Quit False

img=obj.GifImage(-1,1,"")
Response.BinaryWrite(img)
%>

The second way (using MS Word object from 'GetObject' calling)

<%@ Language=VBScript %>
<%
Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")

'Creating an object from document file
set w_doc=GetObject("c:\mydoc.doc")

'Size of shadow
shad=4

sizex=200
sizey=200
obj.CreateImage sizex+shad,sizey+shad,256
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
'Shadow Color
obj.SetColor 2,153,153,153
obj.SetBgColor 0
obj.SetDrawColor 1
'Clearing the image area
obj.FillRect 0,0,sizex-1,sizey-1
obj.CheckObject w_doc,x,y
if x>0 then
	obj.DrawObject w_doc,"CONTENT",2,2,x*3/5,y*3/5
end if

'Drawing a bounding black rectangle
obj.CreateBrush "BS_NULL",2,""
obj.SetDrawColor 0
obj.Rectangle 1,1,sizex-2,sizey-2
obj.SetDrawColor 1
obj.Rectangle 0,0,sizex-1,sizey-1
obj.SetBgColor 0
obj.FillRect sizex,sizey+shad-1,sizex,sizey+shad

'Drawing a shadow
obj.SetBgColor 0
obj.FillRect sizex,0,sizex+shad-1,shad-1
obj.FillRect 0,sizey,shad-1,sizey+shad-1
obj.SetBgColor 2
obj.FillRect sizex,shad,sizex+shad-1,sizey+shad-1
obj.FillRect shad,sizey,sizex+shad-1,sizey+shad-1

obj.WebPalette

img=obj.GifImage(-1,1,"")
Response.BinaryWrite(img)
%>

The third way (using MS Word object directly from file)

<%@ Language=VBScript %>
<%
Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")

'Size of shadow
shad=4

sizex=200
sizey=200
obj.CreateImage sizex+shad,sizey+shad,256
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
'Shadow Color
obj.SetColor 2,153,153,153
obj.SetBgColor 0
obj.SetDrawColor 1
'Clearing the image area
obj.FillRect 0,0,sizex-1,sizey-1
obj.CheckObject "c:\mydoc.doc",x,y
if x>0 then
	obj.DrawObject "c:\mydoc.doc","CONTENT",2,2,x*3/5,y*3/5
end if

'Drawing a bounding black rectangle
obj.CreateBrush "BS_NULL",2,""
obj.SetDrawColor 0
obj.Rectangle 1,1,sizex-2,sizey-2
obj.SetDrawColor 1
obj.Rectangle 0,0,sizex-1,sizey-1
obj.SetBgColor 0
obj.FillRect sizex,sizey+shad-1,sizex,sizey+shad

'Drawing a shadow
obj.SetBgColor 0
obj.FillRect sizex,0,sizex+shad-1,shad-1
obj.FillRect 0,sizey,shad-1,sizey+shad-1
obj.SetBgColor 2
obj.FillRect sizex,shad,sizex+shad-1,sizey+shad-1
obj.FillRect shad,sizey,sizex+shad-1,sizey+shad-1

obj.WebPalette

img=obj.GifImage(-1,1,"")
Response.BinaryWrite(img)
%>

© 1998-2001 Mikhail Tchikalov
Email to contact: mtchikalov@usa.com