VintaSoft Imaging .NET SDK 15.2: Документация для Веб разработчика
В этом разделе
Печать изображений в веб приложении
В этом разделе

1. Классы JavaScript для печати изображений/документов в веб приложении

Класс WebPrintManagerJS - это класс JavaScript, предназначенный для предварительного просмотра и дальнейшей печати изображений/документов. Класс может быть создан на стороне клиента веб-приложения. Для работы класса требуется веб сервис для получения информации об изображении/странице и рендеринга изображения/страницы. В качестве веб сервиса можно использовать контроллер ASP.NET Core Web API (VintasoftImageApiController), контроллер ASP.NET Web API 2 (VintasoftImageApi2Controller) или ASP.NET HTTP обработчик (Vintasoft.Imaging.Web.HttpHandlers.VintasoftImageHandler).

Вот JavaScript код, демонстрирующий, как распечатать каждое второе изображение/страницу из просмотрщика изображений:
// a collection of images, which are opened in image viewer
var imageViewerImages = imageViewer1.get_Images();
// an array of images, which should be printed
var imagesToPrint = [];
// for each second image in image viewer
for (var i = 0; i < imageViewerImages.get_Count(); i += 2) {
    // add image to an array of images, which should be printed
    imagesToPrint.push(imageViewerImages.getImage(i));
}
// create web print manager for images
var printManager = new Vintasoft.Imaging.WebPrintManagerJS(imagesToPrint);
// print images
printManager.print();


Вот JavaScript код, демонстрирующий, как распечатать все изображения/страницы из просмотрщика изображений; печать должна выполняться с пользовательскими настройками (2 изображения/страницы на одной странице принтера):
// an array of images, which should be printed
var imagesToPrint = annotationViewer1.get_Images().toArray();

// the print settings
var printSettings = {
    // column count on page
    columnCount: 2,
    // row count on page
    rowCount: 1,
    // image padding
    imagePadding: 0,
    // a value indicating whether page content should be centered horizontally
    centerHorizontally: false
};

// create web print manager for images
var printManager = new Vintasoft.Imaging.WebPrintManagerJS(imagesToPrint, printSettings);
// print images
printManager.print();


Класс WebAnnotationPrintManagerJS - это JavaScript-класс, предназначенный для предварительного просмотра изображения/страницы с аннотациями и последующей печати. Класс может быть создан на стороне клиента веб-приложения. Для получения информации об изображении/странице и его отображении, а также для работы с аннотациями классу требуется веб сервис. В качестве веб сервисов можно использовать контроллеры ASP.NET Core Web API (VintasoftImageApiController и VintasoftAnnotationCollectionApiController), контроллеры ASP.NET Web API 2 (VintasoftImageApi2Controller и VintasoftAnnotationCollectionApi2Controller) или ASP.NET HTTP обработчики (Vintasoft.Imaging.Web.HttpHandlers.VintasoftImageHandler и Vintasoft.Imaging.Annotation.Web.HttpHandlers.VintasoftAnnotationCollectionHandler).

Вот JavaScript код, демонстрирующий, как распечатать все изображения/страницы из просмотрщика изображений с аннотациями:
// an array of images, which should be printed
var imagesToPrint = annotationViewer1.get_Images().toArray();
// create print manager that allows to print images with annotations;
// specify images, which should be printed;
// specify web service that allows to work with annotations
var printManager = new Vintasoft.Imaging.Annotation.WebAnnotationPrintManagerJS(
    imagesToPrint,
    annotationViewer1.get_AnnotationController());
// print images
printManager.print();


Вот JavaScript просмотрщика изображений с аннотациями, демонстрирующий, как распечатать все изображения/страницы из просмотрщика изображений с аннотациями; печать должна выполняться с пользовательскими настройками (2 изображения/страницы на 1 странице принтера):
// an array of images, which should be printed
var imagesToPrint = annotationViewer1.get_Images().toArray();

// the print settings
var printSettings = {
    // column count on page
    columnCount: 2,
    // row count on page
    rowCount: 1,
    // image padding
    imagePadding: 0,
    // a value indicating whether page content should be centered horizontally
    centerHorizontally: false
};

// create print manager that allows to print images with annotations;
// specify images, which should be printed;
// specify web service that allows to work with annotations;
// specify the printer settings
var printManager = new Vintasoft.Imaging.Annotation.WebAnnotationPrintManagerJS(
    imagesToPrint,
    annotationViewer1.get_AnnotationController(),
    printSettings);
// print images
printManager.print();



2. Пользовательский интерфейс веб просмотрщика документов для печати изображений в веб приложении

Класс WebPrintImagesDialogJS представляет собой UI-диалог, который можно использоваться в UI-контролах WebDocumentViewerJS или WebPdfDocumentEditorControlJS и который позволяет распечатывать изображения/документы, отображаемые в просмотрщике изображений.

Вот скриншот UI-диалога печати (Bootstrap) для WebDocumentViewerJS в веб приложении:


Вот скриншот UI-диалога печати (jQuery UI) для WebDocumentViewerJS в веб приложении:



По умолчанию главное меню содержит кнопку "Печать" в подменю "Файл".


3. Пользовательский интерфейс веб редактора документа для печати DOCX документа в веб приложении

Класс WebUiPrintDocxDocumentSettingsDialogJS представляет собой UI-диалог, который можно использовать в UI-контроле WebDocumentEditorJS и который позволяет распечатать DOCX документ, отображаемый в редакторе документа.

Вот скриншот UI-диалога печати (Bootstrap) для WebDocumentEditorJS в веб приложении:


Вот скриншот UI-диалога печати (jQuery UI) для WebDocumentEditorJS в веб приложении:



По умолчанию главное меню содержит кнопку "Печать" в подменю "Файл".