Extracts an image from a file and adds it to the current page.




ImageID = Doc.AddImageFile(Path, Frame)



Name Type Description
Path String The path to the image file.
Frame Long Some image formats support multiple frames or pages. The first frame is frame one.
ImageID Long The Object ID of the newly added Image object.




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

Images embedded using this method are always inserted using pass-through mode. Pass-through mode is faster than indirect mode. It allows the preservation of compression settings, native color spaces and ICC color profiles. It allows vector graphics to be maintained in vector format. However, it supports a limited range of image formats - JPEG, JPEG 2000, TIFF, EMF, WMF, PS (PostScript) or EPS (Encapsulated PostScript).

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.

The image is scaled to fill the current Rect. It is transformed using the current Transform.

If the width or height of the current rectangle is zero, the image is auto-sized. If you are working in TopDown mode, the image is positioned with its top left pinned at the location indicated by the rectangle. If you are not in TopDown mode, the bottom left of the image is pinned at the location indicated by the rectangle. In both cases, the natural dimensions of the supplied image are used to determine the displayed width and height resulting in a 72-dpi output.

Transparency. Occasionally, you may find that you need to invert the transparency of your image. To do this, you can assign a decode array using the ID returned from this method.

To invert the transparency:

theDoc.SetInfo theDoc.GetInfo(theID, "XObject"), "/SMask*/Decode", "[1 0]"

A similar technique can be used for inverting or altering color levels on the image itself.

To invert an RGB image:

theDoc.SetInfo theDoc.GetInfo(theID, "XObject"), "/Decode", "[1 0 1 0 1 0]"




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("ABCpdf13.Doc")
theDoc.Rect = "0 0 0 0"
theDoc.AddImageFile "c:\mypics\mypic.jpg", 1
theDoc.Save "c:\mypdfs\docaddimage.pdf"