PrizmDoc® Viewer v13.26 Release - Updated January 16, 2024
PrizmDoc Viewer / API Reference / Viewer Control / Namespace: PCCViewer / Class: ImageStamps
Class: ImageStamps

PCCViewer. ImageStamps

new ImageStamps(object)

The constructor for a ImageStamp Object. 'ImageStamp' object represents APIs for requesting the images and source from the server.

Example

 var options = { imageHandlerUrl: "../pcc.ashx" }
 var stamp = PCCViewer.ImageStamps(options);

Parameters:

Name Type Description
object object

with link to imageHandler URL.

Methods

getImageSourceURL(imageStampId)

Returns the image source URL for the imageStampId

Example

 var options = { imageHandlerUrl: "../pcc.ashx" }
 var stampApi = new PCCViewer.ImageStamps(options);

 var imageUrl = stampApi.getImageSourceURL(imageStampId);

Parameters:

Name Type Description
imageStampId string

reqestImageSourceBase64()

Deprecated since v13.4 (use the PCCViewer.ImageStamps#requestImageSourceBase64 method instead).

requestImageSourceBase64(imageStampId) → {PCCViewer.Promise}

Retrieves the data URL and data hash from the server for the provided image stamp ID. This method utilizes an asynchronous server request to fetch the data and returns a PCCViewer.Promise to resolve the request.

The onFulfilled callback will receive an object containing the dataUrl (a base64 encoded image source) and dataHash (an encoded unique ID) of the image stamp.

If unable to retrieve the image stamp data URL and data hash from the 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.

Example

var options = { imageHandlerUrl: "../pcc.ashx" };
var stampApi = new PCCViewer.ImageStamps(options);

var stampPromise = stampApi.requestImageStampList();

stampPromise.then(
    function onSuccess(data) {
        var base64Promise = stampApi.requestImageSourceBase64(data.imageStamps[0].id);

        base64Promise.then(
            function onSuccess(imageSource) {
                var pageNumber = 1;
                var rectangle = { x: 30, y: 30, width: 100, height: 100 };
                var mark = viewer.viewerControl.addMark(pageNumber, "ImageStampAnnotation");
                mark.setImage({
                    dataUrl: imageSource.dataUrl, id: imageSource.dataHash
                });
                mark.setRectangle(rectangle);
            }
        );

    },
    function onFailure(error) {
        alert(error.message ? error.message : error);
    }
);

Parameters:

Name Type Description
imageStampId string

A unique ID that corresponds to an image stamp stored on the server.

Returns:

Type
PCCViewer.Promise

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.

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.requestImageSourceBase64(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)
     }
 );

Parameters:

Name Type Description
object object

with web handler link assigned to the imageHandlerUrl property.

Returns:

a Promise object.

Type
PCCViewer.Promise

Documentation generated by JSDoc 3.6.10 on Fri Dec 15 2023 17:21:57 GMT+0000 (Coordinated Universal Time)