VintaSoft Imaging .NET SDK 15.1: Документация для Веб разработчика
В этом разделе
Открытие изображений
В этом разделе
SDK может открывать изображения из файлов изображений и документов следующих форматов:

Открытие файла изображения, хранящегося на сервере

SDK может открывать изображения, хранящиеся на сервере.

Вот JavaScript код, который демонстрирует, как очистить коллекцию изображений в веб-просмотрщике, загрузить изображения из TIFF файла, расположенного на сервере, и добавить созданные изображения в коллекцию:
// identifier of multipage TIFF file, which is located on server
var fileId = "multipage.tif";
// get image collection of image viewer
var images = imageViewer.get_Images();
// clear image collection and add all images from TIFF file to the image collection
images.openFile(fileId);



Вот JavaScript код, который демонстрирует, как загрузить изображения из TIFF файла, расположенного на сервере, и добавить созданные изображения в коллекцию веб-просмотрщика изображений:
// File is opened successfully. This function is obligatory because without this function the image collection will be cleared.
function __openFile_success(data) {
    // an array of WebImageJS objects, which represent images from opened TIFF file
    var newImages = data.images;
    // add images to the end of image collection
    images.addRange(newImages);
}

// identifier of multipage TIFF file, which is located on server
var fileId = "multipage.tif";
// get image collection of image viewer
var images = imageViewer.get_Images();
// add all images from multipage TIFF file to the end of image collection
images.openFile(fileId, __openFile_success);



Вот JavaScript код, который демонстрирует, как очистить коллекцию веб-просмотрщика изображений, загрузить изображения из нескольких файлов, расположенных на сервере, и добавить созданные изображения в коллекцию:
// array of file identifiers
var filesIds = ["image.png", "multipage.tif", "multipage.pdf"];
// get image collection of image viewer
var images = imageViewer.get_Images();
// clear image collection and add all images from image files to the image collection
images.openFiles(filesIds);



Вот JavaScript код, который демонстрирует, как загрузить изображения из нескольких файлов, расположенных на сервере, и добавить изображения в коллекцию веб-просмотрщика изображений:
// File is opened successfully. This function is obligatory because without this function the image collection will be cleared.
function __openFile_success(data) {
    // an array of WebImageJS objects, which represent images from opened image files
    var newImages = data.images;
    // add images to the end of image collection
    images.addRange(newImages);
}

// array of file identifiers
var filesIds = ["image.png", "multipage.tif", "multipage.pdf"];
// get image collection of image viewer
var images = imageViewer.get_Images();
// add all images from image files to the end of image collection
images.openFiles(filesIds, __openFile_success);



Вот JavaScript код, который демонстрирует, как создать веб изображение, связанной с первой страницей TIFF файла, и добавить созданное изображение в коллекцию веб-просмотрщика изображений:
// identifier of multipage TIFF file, which is located on server
var fileId = "multipage.tif";
// create source of image file (with default image service)
var imageSource = new Vintasoft.Shared.WebImageSourceJS(fileId);
// create WebImageJS object, which is associated with the first page of multipage TIFF file
var image = new Vintasoft.Shared.WebImageJS(imageSource, 0);

// get image collection of image viewer
var images = imageViewer.get_Images();
// add new image to the image collection of image viewer
// Important: Image collection must not contain identical image, i.e. images with the same source identifier and page index.
images.add(image);




Открытие файла изображения, хранящегося в базе данных

SDK может открывать изображения, хранящиеся в базе данных или любом другом хранилище данных. Подробную информацию смотрите в статье: Как просматривать изображения из базы данных.