Adds an image to the current page.

 

   
Syntax
 
     

ImageID = Doc.AddImage(ImageSpec [, Frame [, SrcRect]])

 

   
Params
 
     
Name   Type   Description
ImageSpec Object

The image to be added to the page. See below for different ways of specifying images.

Frame Long

Some image types support multiple frames or pages. You can specify the frame you want added using this optional argument. The default is one to indicate the first frame.

SrcRect String

Some image types support source rectangles. You can specify the portion of the image you want drawn using this optional argument. The default value is the rectangle encompassing the entire image.

ImageID Long The Object ID of the newly added Image Object.

 

   
Notes
 
     

Adds an image to the current page returning the ID of the newly added object.

The image is scaled to fill the current rectangle. It is transformed using the current transformation matrix.

If the width or height of the current rectangle is zero the image is auto-sized. It is positioned with the bottom left of the image at the location indicated by the rectangle and the natural dimensions of the supplied image used to determine the width and height of the image object.

The table below details the ways in which images can be specified and the conditions under which the optional Frame and SrcRect parameters are used.

Image Specifier Notes Uses Frame Uses SrcRect
Image Object

If the image specifier is an Image object then the Selection of the current Frame is added to the document.

Images from these are embedded using indirect mode

Indirect mode is not as fast as pass-through mode. However it allows greater flexibility and the use of many different image formats.

See Notes See Notes
File Path

If the image specifier is a string specifying a file path it is assumed that it represents a JPEG, TIFF, EMF or WMF file.

Images from these file types are embedded using pass-through mode.

In general you should only embed JPEG or EMF images using pass-through mode. Use the Image object to embed other types of file such as TIFF or BMP.

Note that not all EMF or WMF files can be represented in terms of PDF vectors. If this is the case you should look at using the Image object to convert these objects prior to embedding.

Yes No
URL

If the image specifier is a string specifying a URL it is assumed that it represents an HTML file.

For further details see the HTML Support section of this document.

Yes No
HTML

If the image specifier is a string and the first character in the string is an open angle bracket it is assumed that the string is HTML.

For further details see the HTML Support section of this document.

Yes No
Raw Data

If the image specifier is an Array of Bytes it is assumed that it contains raw JPEG, TIFF, EMF or WMF data.

Images from these file types are embedded using pass-through mode

In general you should only embed JPEG or EMF images using pass-through mode. Use the Image object to embed other types of file such as TIFF or BMP.

Note that not all EMF or WMF files can be represented in terms of PDF vectors. If this is the case you should look at using the Image object to convert these objects prior to embedding.

Yes No
Doc Object

If the image specifier is a Doc object then one page of the source document is drawn onto the current page.

The page to be drawn is indicated by the optional Frame Parameter and the source rectangle by the optional SrcRect parameter.

Yes Yes
ImageID

If the image specifier is a number it is assumed that it is an object ID obtained from a previous call to AddImage.

You can use this facility to add commonly used graphics such as watermarks. The raw image data is inserted only once which means that PDF size is greatly reduced.

This facility is only possible with raster images - those obtained by calling AddImage with an Image Object, a File Path or Raw Data.

No No

 

   
Example
 
     

The following code adds an image to the current page positioned at the bottom left. The width and height of the image are automatically inferred from the file supplied.

Set theDoc = Server.CreateObject("ABCpdf3.Doc")
theDoc.Rect = "0 0 0 0"
theDoc.AddImage "c:\mypic.jpg"
t
heDoc.Save "c:\docaddimage.pdf"


docaddimage.pdf

 

   

 

Browser Based Help. Published by chm2web software.