Click or drag to resize

setImage Method

Sets the image used by this ImageShape.

Syntax
JavaScript
function setImage(key);

Parameters

key

Type: String

Object data key for use with a PdfIntegrationProvider which implements the ProcessObjectDataRequest method; or

a data URL (e.g. "data:image/png;base64,iVBO..."); or

another PdfObject which has an image (e.g. a ImageShape)

Return Value

Type: Boolean

true if operation is started successfully; otherwise, false.

Remarks

If this PdfObject is not an ImageShape, this method will always return false.

This method does not immediately set the image as sending the key to the server, processing it, and applying it to the object requires a server request. To check if an image has been applied, use the hasImage Method.

Examples

Add a new image object to the first page:

JavaScript
var myApi = new PdfWebControlApi("PdfWebControl1"); // where "PdfWebControl1" is the ID (ClientID) assigned to the PdfWebControl instance

//Add object
var newImage = myApi.getPage(1).addObject(myApi.ObjectType.ImageShape);

//Set image for object using key (see Easy-Integration.aspx sample for more information)
newImage.setImage("signature");

//As setImage() does not immediately set the image, we can check that the image was set in 1 second
window.setTimeout(function(){ if(!newImage.hasImage()) {window.alert("Image was not set!");} }, 1000);
See Also