VintaSoft Imaging .NET SDK 12.4: Documentation for Web developer
In This Topic
    Download images from server
    In This Topic

    1. JavaScript class for downloading image file from server

    VintasoftFileAPI class is static JavaScript class that helps to manipulate files on server. The class requires a web service that manipulates files on server. As the web service can be used ASP.NET Core Web API controller (Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController), ASP.NET Web API 2 controller (Vintasoft.Imaging.Web.Api2Controllers.VintasoftFileApi2Controller) or ASP.NET HTTP handler (Vintasoft.Imaging.Web.HttpHandlers.VintasoftFileHandler).

    Here is an example that demonstrates how to download an image file, which is associated with image focused in image viewer:
    // The file downloading process is finished successfully.
    function __downloadImageFile_success(data){
        // get a blob, which contains data of downloaded file
        var blob = data.blob;
        // save blob
        //...
    }
    
    // The file downloading process is failed.
    function __downloadImageFile_error(data){
        // show information about error
    }
    
    // get image, which is focused in image viewer
    var focusedImage = imageViewer.get_FocusedImage();
    // if image exists
    if (focusedImage != undefined){
        // get identifier of focused image
        var id = focusedImage.get_ImageId();
        // send an asynchronous request for downloading of image file from server
        Vintasoft.Imaging.VintasoftFileAPI.downloadImageFile(id, __downloadImageFile_success, __downloadImageFile_error);
    }
    


    2. Web Document Viewer UI for downloading image file from server

    WebUiElementsFactoryJS class contains registered element with identifier "downloadImageButton", which represents WebUiButtonJS object that allows to download an image file, which is associated with image focused in image viewer, from server.
    When the "downloadImageButton" is clicked, VintaSoft Web Document Viewer starts the asynchronous image file downloading process with description "Download file" and fires "asyncOperationStarted", "asyncOperationFinished" and "asyncOperationFailed" events for notifiying about the process status (eventArgs.description == "Download file").
    The file toolbar panel (WebUiFileToolbarPanelJS object) by default contains the "downloadImageButton" button.

    Here is screenshot of "downloadImageButton" button in web application: