new ImageStamps(object)
The constructor for a ImageStamp
Object. 'ImageStamp' object represents APIs for requesting the images and source from the server.
Parameters:
Name | Type | Description |
---|---|---|
object |
object |
with link to imageHandler URL. |
Example
var options = { imageHandlerUrl: "../pcc.ashx" }
var stamp = PCCViewer.ImageStamps(options);
Methods
getImageSourceURL(imageStampId)
Returns the image source URL for the imageStampId
Parameters:
Name | Type | Description |
---|---|---|
imageStampId |
string |
Example
var options = { imageHandlerUrl: "../pcc.ashx" }
var stampApi = new PCCViewer.ImageStamps(options);
var imageUrl = stampApi.getImageSourceURL(imageStampId);
requestImageSourceBase64(imageStampId) → {PCCViewer.Promise}
Retrieves the dataUrl (base64 image source), and dataHash (unique id) from the server for the provided imagesStampId
If unable to retrieve image stamp data URL and dataHash from server, then the returned PCCViewer.Promise
object is rejected with the reason set to a PCCViewer.Error
object with its code property set to ImageStampDataFail.
If AJAX is not supported, then the returned PCCViewer.Promise
object is rejected with the reason set to a PCCViewer.Error
object with its code property set to AjaxUnsupported.
If a server error is encountered, then the returned PCCViewer.Promise
object is rejected with the reason set to a PCCViewer.Error
object with its code property set to Error.
Parameters:
Name | Type | Description |
---|---|---|
imageStampId |
string |
Returns:
a Promise object, on success returns a JSON object, on failure promise is rejected with reason. Returned JSON object will have dataUrl, and dataHash properties: dataUrl: base64 encoded image source dataHash: Encoded unique Id
- Type
- PCCViewer.Promise
Example
var options = { imageHandlerUrl: "../pcc.ashx" }
var stampApi = new PCCViewer.ImageStamps(options);
var imageStamps = {};
var base64Source = null;
var stampPromise = stampApi.requestImageStampList();
stampPromise.then(
function onSuccess(data) {
imageStamps = data.imageStamps;
var base64Promise = stampApi.reqestImageSourceBase64(imageStamps[0].id);
base64Promise.then(
function onSuccess(imageSource) {
base64Source = imageSource
var pageNumber = 1;
var rectangle = { x: 30, y: 30, width: 100, height: 100 };
var mark = viewer.viewerControl.addMark(pageNumber, "ImageStampAnnotation");
mark.setImage({
dataUrl: base64Source.dataUrl, id: base64Source.dataHash
});
mark.setRectangle(rectangle);
}
);
},
function onFailure(error) {
alert(error.message ? error.message : error)
}
);
requestImageStampList(object) → {PCCViewer.Promise}
Retrieves the image stamp list from the server.
If a server error is encountered, then the returned PCCViewer.Promise
object is rejected with the reason set to a PCCViewer.Error
object with its code property set to Error.
If AJAX is not supported, then the returned PCCViewer.Promise
object is rejected with the reason set to a PCCViewer.Error
object with its code property set to AjaxUnsupported.
Parameters:
Name | Type | Description |
---|---|---|
object |
object |
with web handler link assigned to the |
Returns:
a Promise object.
- Type
- PCCViewer.Promise
Example
var options = { imageHandlerUrl: "../pcc.ashx" }
var stampApi = new PCCViewer.ImageStamps(options);
var imageStamps = {};
var base64Source = null;
var stampPromise = stampApi.requestImageStampList();
stampPromise.then(
function onSuccess(data) {
imageStamps = data.imageStamps;
var base64Promise = stampApi.reqestImageSourceBase64(imageStamps[0].id);
base64Promise.then(
function onSuccess(imageSource) {
base64Source = imageSource
var pageNumber = 1;
var rectangle = { x: 30, y: 30, width: 100, height: 100 };
var mark = viewer.viewerControl.addMark(pageNumber, "ImageStampAnnotation");
mark.setImage({
dataUrl: base64Source.dataUrl, id: base64Source.dataHash
});
mark.setRectangle(rectangle);
}
);
},
function onFailure(error) {
alert(error.message ? error.message : error)
}
);