VintaSoft Imaging .NET SDK 12.4: Documentation for Web developer
In This Topic
    View thumbnails in HTML5 web browser
    In This Topic

    1. JavaScript UI control for thumbnail viewing in HTML5 web browser

    The WebThumbnailViewerJS class is a JavaScript control for viewing thumbnails in any HML5 compatible web browser. The class can be created on a client-side of web application. The class requires a web service for getting information about image and rendering a thumbnail. As the web service can be used ASP.NET Core Web API controller (ASP.NET Core), ASP.NET Web API 2 controller (ASP.NET MVC 5), or any other .NET compatible web service.

    Tutorials, which describe how to embed the web thumbnail viewer into an ASP.NET application can be found here:

    WebThumbnailViewerJS can work separately and in this case:
    WebThumbnailViewerJS can work as a slave viewer of another WebThumbnailViewerJS or WebImageViewerJS, and in this case:
    Here is an example that demonstrates how to add images to the web image viewer, add link between web image viewer and web thumbnail viewer:
    // create images
    var imageSource = new Vintasoft.Shared.WebImageSourceJS("/Images/SourceImage.pdf");
    var image1 = new Vintasoft.Shared.WebImageJS(imageSource, 0);
    var image2 = new Vintasoft.Shared.WebImageJS(imageSource, 1);
    // create an image viewer
    var imageViewer1 = new Vintasoft.Imaging.UI.WebImageViewerJS("WebImageViewer1");
    // create a thumbnail viewer
    var thumbnailViewer1 = new Vintasoft.Imaging.UI.WebThumbnailViewerJS("WebThumbnailViewer1");
    // create a link between image viewer and thumbnail viewer
    thumbnailViewer1.set_MasterViewer(imageViewer1);
    // get an image collection of image viewer
    var images = imageViewer1.get_Images();
    // add images to the image collection
    images.addRange([image1, image2]);
    


    1.1. Appearance of thumbnails

    1.1.1. Size of thumbnails

    Thumbnails have two sizes:
    The physical size of thumbnails can be set via set_ThumbnailSize function. The minimal physical size of thumbnail is 32x32 pixels, the maximal physical size of thumbnail is 1024x1024 pixels.

    The visible size of thumbnails can be set via set_ThumbnailScale function. The visible size is calculated as multiplication of physical size and scaling factor. Here is a list of scaling factors:

    1.1.2. Custom appearance of thumbnails

    The WebThumbnailAppearanceJS class allows to define a visual appearance of thumbnail:

    Each appearance allows to specify back color, background style and border style of thumbnail.

    Here is an example that demonstrates how to create thumbnail appearance and set it as "normal" style in web thumbnail viewer:
    var appearance = new Vintasoft.Imaging.WebThumbnailAppearance("red", "3px solid green");
    thumbnailViewer1.set_NormalThumbnailAppearance(appearance);
    

    1.1.3. Adding text to thumbnail

    The getThumbnailCanvas function allows to get a canvas, where thumbnail is drawn. Canvas can be used for drawing additional information (for example, text) on a thumbnail.

    Here is an example that demonstrates how to add a text with index of thumbnail under the image of thumbnail:
    // get the thumbnail canvas
    var canvas = thumbnailViewer1.get_ThumbnailCanvas(0);
    
    // draw a text on the thumbnail canvas
    
    var width = canvas.width;
    var height = canvas.height;
    var canvasContext = canvas.getContext("2d");
    canvasContext.font = "12px Arial";
    canvasContext.textAlign = "center";
    canvasContext.fillText("# 1", width / 2, height - 3);
    


    1.2. Manipulation of thumbnails

    1.2.1. Rendering of thumbnails

    WebThumbnailViewerJS renders thumbnails and generates:
    By default are generated all thumbnails. The set_GenerateOnlyVisibleThumbnails function allows to specify whether only visible thumbnails must be generated.

    1.2.2. Multiselection

    WebThumbnailViewerJS allows to choose several thumbnails at the same time. The indices of selected thumbnails can be received using the get_SelectedIndices function. The indices of selected thumbnails can be specified using the set_SelectedIndices function.


    1.2.3. Rotation of thumbnails

    The set_ViewRotationAngle function allows to set an orthogonal rotation angle of thumbnail in the thumbnail viewer.


    1.2.4. Caching thumbnails on the server

    The set_UseCache function allows to specify whether caching of the thumbnails in files on server is necessary.

    If caching is enabled, the web thumbnail viewer will do the following steps:
    If caching is not enabled, the web thumbnail viewer will render thumbnail for each new request.

    The thumbnail can be stored in cache as PNG image (WebImageTypeEnumJS.Url) or as a Base64 string (WebImageTypeEnumJS.Base64). By default the web thumbnail viewer stores thumbnails in cache as PNG images. Used format can be get using WebThumbnailViewerJS.get_ThumbnailsFormat function. Used format can be set using WebThumbnailViewerJS.set_ThumbnailsFormat function.


    2. Web Document Viewer UI for thumbnail viewing in HTML5 web browser

    The WebUiThumbnailViewerPanelJS class represents a web UI panel that can be used in web document viewer and allows to display a thumbnail viewer. Panel can be shown in side panel or separately.
    Panel will create web thumbnail viewer if "annotations" flag is NOT enabled in web document viewer settings.
    Panel will create web annotated thumbnail viewer if "annotations" flag is enabled in web document viewer settings.

    The WebThumbnailViewerSettingsDialogJS class represents an UI dialog that can be used in web document viewer and allows to view and edit the thumbnail viewer settings.

    Here is screenshot of thumbnail viewer panel in web application: