VintaSoft Imaging .NET SDK 15.2: Документация для Веб разработчика
В этом разделе
Добавление веб просмотрщика документов в приложение "ASP.NET Core Web App (Model-View-Controller)"
В этом разделе
В этом руководстве показано, как создать пустое приложение "ASP.NET Core Web App (Model-View-Controller)" в Visual Studio .NET 2026 и добавить средство просмотрщик документов (с возможностью открывать изображения и документы (PDF, DOCX, PPTX, XLSX), извлекать / искать текст, комментировать документы) в приложение ASP.NET Core.

Вот шаги, которые необходимо выполнить:
  1. Создайте пустое приложение "ASP.NET Core Web App (Model-View-Controller)".

    Откройте Visual Studio .NET 2026 и создайте новый проект типа приложения "ASP.NET Core Web App (Model-View-Controller)":

    Настройте проект для использования .NET 10.0:

  2. Серверная сторона: Добавьте ссылки на nuget-пакеты Vintasoft в приложение ASP.NET Core.

    Добавьте ссылки на nuget-пакеты "Vintasoft.Imaging.Annotation.AspNetCore.ApiControllers", "Vintasoft.Imaging.Annotation.Pdf", "Vintasoft.Imaging.Office.OpenXml" в приложение ASP.NET Core. Другие необходимые nuget-пакеты будут добавлены автоматически.



  3. Серверная сторона: Укажите движок рисования, который должен использоваться VintaSoft Imaging .NET SDK для рисования 2D-графики.

    Если ASP.NET Core приложение планируется использовать в среде Windows или Linux, рекомендуется применять графический движок SkiaSharp.
    Если ASP.NET Core приложение будет использоваться только в среде Windows, можно применять как графический движок System.Drawing, так и SkiaSharp.

    Вот шаги, которые необходимо выполнить для использования движка SkiaSharp:
    • Добавьте ссылку на nuget-пакет "Vintasoft.Imaging.Drawing.SkiaSharp". Ссылка на nuget-пакет "SkiaSharp" версии 4.151.1 будет добавлена автоматически.
    • Откройте файл "Program.cs", добавьте в начало файла строку кода "Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();" - добавленный код указывает, что VintaSoft Imaging .NET SDK должен использовать библиотеку SkiaSharp для отрисовки 2D-графики.

    Вот шаги, которые необходимо выполнить для использования движка System.Drawing:
    • Добавьте ссылку на nuget-пакет "Vintasoft.Imaging.Gdi".
    • Откройте файл "Program.cs", добавьте в начало файла строку кода "Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();" - добавленный код указывает, что VintaSoft Imaging .NET SDK должен использовать библиотеку System.Drawing для отрисовки 2D-графики.

  4. Серверная сторона: Добавьте Newtonsoft JSON для десериализации аннотаций.

      Добавьте ссылку на nuget-пакет "Microsoft.AspNetCore.Mvc.NewtonsoftJson" версии 10.0.0.
  5. Серверная сторона: Создайте веб сервисы, которые позволяют загружать/скачивать файлы, управлять коллекцией изображений, получать информацию об изображениях, получать миниатюры, рендерить тайлы изображений, извлекать/искать текст и комментировать документ.

    • Создайте веб сервис, позволяющий загружать/скачивать файл

      • Нажмите правую кнопку мыши на папке "Controllers" и выберите меню "Add => Controller..." из контекстного меню
      • Выберите шаблон "Empty API controller", установите имя контроллера "MyVintasoftFileApiController" и нажмите кнопку "Add".
      • Укажите, что класс MyVintasoftFileApiController является производным от класса Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController

        Вот исходные коды класса MyVintasoftFileApiController:
        using Microsoft.AspNetCore.Hosting;
        
        namespace WebApplication1.Controllers
        {
            public class MyVintasoftFileApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController
            {
        
                public MyVintasoftFileApiController(IWebHostEnvironment hostingEnvironment)
                    : base(hostingEnvironment)
                {
                }
        
            }
        }
        
    • Создайте веб сервис, позволяющий управлять коллекцией изображений

      • Нажмите правую кнопку мыши на папке "Controllers" и выберите меню "Add => Controller..." из контекстного меню
      • Выберите шаблон "Empty API controller", установите имя контроллера "MyVintasoftImageCollectionApiController" и нажмите кнопку "Add".
      • Укажите, что класс MyVintasoftImageCollectionApiController является производным от класса Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageCollectionApiController

        Вот исходные коды класса MyVintasoftImageCollectionApiController:
        namespace WebApplication1.Controllers
        {
            public class MyVintasoftImageCollectionApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageCollectionApiController
            {
        
                public MyVintasoftImageCollectionApiController(IWebHostEnvironment hostingEnvironment)
                    : base(hostingEnvironment)
                {
                }
        
            }
        }
        
    • Создайте веб сервис, который позволяет получать информацию об изображениях, получать миниатюры, рендерить тайлы изображений, извлекать/искать текст

      • Нажмите правую кнопку мыши на папке "Controllers" и выберите меню "Add => Controller..." из контекстного меню
      • Выберите шаблон "Empty API controller", установите имя контроллера "MyVintasoftImageApiController" и нажмите кнопку "Add".
      • Укажите, что класс MyVintasoftImageApiController является производным от класса Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageApiController

        Вот исходные коды класса MyVintasoftImageApiController:
        namespace WebApplication1.Controllers
        {
            public class MyVintasoftImageApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageApiController
            {
        
                public MyVintasoftImageApiController(IWebHostEnvironment hostingEnvironment)
                    : base(hostingEnvironment)
                {
                }
        
            }
        }
        
    • Создайте веб сервис, который позволяет комментировать изображения и документы

      • Нажмите правую кнопку мыши на папке "Controllers" и выберите меню "Add => Controller..." из контекстного меню
      • Выберите шаблон "Empty API controller", установите имя контроллера "MyVintasoftAnnotationCollectionApiController" и нажмите кнопку "Add".
      • Укажите, что класс MyVintasoftAnnotationCollectionApiController является производным от класса Vintasoft.Imaging.Annotation.AspNetCore.ApiControllers.VintasoftAnnotationCollectionApiController

        Вот исходные коды класса MyVintasoftAnnotationCollectionApiController:
        namespace WebApplication1.Controllers
        {
            public class MyVintasoftAnnotationCollectionApiController :
                Vintasoft.Imaging.Annotation.AspNetCore.ApiControllers.VintasoftAnnotationCollectionApiController
            {
        
                public MyVintasoftAnnotationCollectionApiController(IWebHostEnvironment hostingEnvironment)
                    : base(hostingEnvironment)
                {
                }
            }
        }
        
  6. Клиентская сторона: Добавьте JavaScript-библиотеки в проект.

    • Добавьте папку "wwwroot\lib\Vintasoft" в приложение ASP.NET Core.

    • Скопируйте файлы Vintasoft.Shared.js, Vintasoft.Imaging.js, Vintasoft.Imaging.css, Vintasoft.Imaging.Annotation.js, Vintasoft.Imaging.Annotation.css, Vintasoft.Imaging.DocumentViewer.js из папки "<InstallPath>\VintaSoft Imaging .NET 15.2\Bin\JavaScript\" в папку "wwwroot\lib\Vintasoft\".

    • Укажите, какие "стандартные" UI-диалоги должны спользоваться веб просмотрщиком документов
      • Если веб просмотрщик документов долен использовать готовые к использованию "стандартные" UI-диалоги Bootstrap:
        • Добавьте библиотеки Bootstrap и jQuery в проект.
        • Скопируйте файлы Vintasoft.Imaging.Dialogs.Bootstrap.js, Vintasoft.Imaging.Annotation.Dialogs.Bootstrap.js и Vintasoft.Imaging.DocumentViewer.Dialogs.Bootstrap.js из папки "<InstallPath>\VintaSoft Imaging .NET 15.2\Bin\JavaScript\" в папку "wwwroot\lib\Vintasoft\".
      • Если веб просмотрщик документов должен использовать готовые к использованию "стандартные" UI-диалоги jQuery UI:
        • добавьте библиотеки jQuery и jQuery UI в проект;
        • Скопируйте файлы Vintasoft.Imaging.Dialogs.jQueryUI.js, Vintasoft.Imaging.Annotation.Dialogs.jQueryUI.js и Vintasoft.Imaging.DocumentViewer.Dialogs.jQueryUI.js из папки "<InstallPath>\VintaSoft Imaging .NET 15.2\Bin\JavaScript\" в папку "wwwroot\lib\Vintasoft\".
      • Если веб просмотрщик документов должно использовать пользовательские "стандартные" UI-диалоги, прочтите, как создавать пользовательские "стандартные" UI-диалоги здесь .

  7. Клиентская сторона: Добавьте JavaScript-код, который позволяет отображать документы, искать и извлекать текст, аннотировать документы.

    • Создайте папку "wwwroot\UploadedImageFiles\SessionID" и скопируйте тестовый PDF документ "<SdkInstallPath>\VintaSoft\Imaging .NET 15.2\Images\VintasoftImagingDemo.pdf" в созданную папку. Этот документ будет отображаться в веб просмотрщике документов.

    • Откройте файл "Views\Home\Index.cshtml".



      Добавьте ссылки на используемые JavaScript-библиотеки:
      • Если вы используете диалоговые окна Bootstrap, добавьте ссылки на файлы Bootstrap и Vintasoft JavaScript-файлы.
        Вот HTML-код, который добавляет ссылки на файлы Bootstrap и Vintasoft JavaScript-файлы:
        <link rel="stylesheet" type="text/css" href="~/lib/bootstrap/dist/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.Annotation.css">
        
        <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js" type="text/javascript"></script>
        
        <script src="~/lib/Vintasoft/Vintasoft.Shared.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dialogs.Bootstrap.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Annotation.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Annotation.Dialogs.Bootstrap.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.DocumentViewer.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.DocumentViewer.Dialogs.Bootstrap.js" type="text/javascript"></script>
        
        

      • Если вы используете диалоговые окна jQuery UI, добавьте ссылки на jQuery-файлы и Vintasoft JavaScript-файлы.
        Вот HTML-код, который добавляет ссылки на jQuery-файлы и Vintasoft JavaScript-файлы:
        <link rel="stylesheet" type="text/css" href="~/js/jquery-ui-css/jquery-ui.min.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.Annotation.css">
        
        <script src="~/js/jquery-3.3.1.min.js" type="text/javascript"></script>
        <script src="~/js/jquery-ui.min.js" type="text/javascript"></script>
        
        <script src="~/lib/Vintasoft/Vintasoft.Shared.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dialogs.jQueryUI.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Annotation.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Annotation.Dialogs.jQueryUI.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.DocumentViewer.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.DocumentViewer.Dialogs.jQueryUI.js" type="text/javascript"></script>
        
        


      Добавьте в веб-представление HTML-разметку (div-элемент, который будет отображать веб просмотрщик документов):

      Вот код HTML-разметки:
      <div class="text-center">
          <h1>VintaSoft Document Viewer Demo (ASP.NET Core)</h1>
      
          <div id="documentViewerContainer" class="documentViewerContainer"></div>
      </div>
      
      

    • Откройте файл "wwwroot\css\site.css", добавьте CSS-стиль для "documentViewerContainer" в файл "site.css":
      html {
        font-size: 14px;
      }
      
      @media (min-width: 768px) {
        html {
          font-size: 16px;
        }
      }
      
      .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
        box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
      }
      
      html {
        position: relative;
        min-height: 100%;
      }
      
      body {
        margin-bottom: 60px;
      }
      
      .form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
        color: var(--bs-secondary-color);
        text-align: end;
      }
      
      .form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
        text-align: start;
      }
      
      .documentViewerContainer {
          height: 800px;
      }
      
      


    • Откройте файл "wwwroot\js\site.js", добавьте JavaScript-код, который инициализирует и создает веб просмотрщик документов:

      Вот JavaScript-код, который инициализирует и отображает веб просмотрщик документов:
      // set the session identifier
      Vintasoft.Shared.WebImagingEnviromentJS.set_SessionId("SessionID");
      
      // specify web services, which should be used by Vintasoft Web Document Viewer
      Vintasoft.Shared.WebServiceJS.defaultFileService =
          new Vintasoft.Shared.WebServiceControllerJS("/vintasoft/api/MyVintasoftFileApi");
      Vintasoft.Shared.WebServiceJS.defaultImageCollectionService =
          new Vintasoft.Shared.WebServiceControllerJS("/vintasoft/api/MyVintasoftImageCollectionApi");
      Vintasoft.Shared.WebServiceJS.defaultImageService =
          new Vintasoft.Shared.WebServiceControllerJS("/vintasoft/api/MyVintasoftImageApi");
      Vintasoft.Shared.WebServiceJS.defaultAnnotationService =
          new Vintasoft.Shared.WebServiceControllerJS("/vintasoft/api/MyVintasoftAnnotationCollectionApi");
      
      // create settings for document viewer with annotation support
      var docViewerSettings =
          new Vintasoft.Imaging.DocumentViewer.WebDocumentViewerSettingsJS("documentViewerContainerId", "documentViewerLocalizationId", true);
      // specify that the main menu should contain the annotation menu
      docViewerSettings.set_ShowAnnotationMenuInMainMenu(true);
      // specify that the side panel should contain the annotation list panel
      docViewerSettings.set_ShowAnnotationListSidePanel(true);
      // specify that web document viewer allows to navigate document
      docViewerSettings.set_CanNavigateDocument(true);
      // specify that web document viewer allows to select text
      docViewerSettings.set_CanSelectText(true);
      // specify that web document viewer allows to search text
      docViewerSettings.set_CanSearchText(true);
      
      // create the document viewer
      var docViewer = new Vintasoft.Imaging.DocumentViewer.WebDocumentViewerJS(docViewerSettings);
      
      // create visual tool that allows to work with annotations, navigate document, select text, pan page in viewer
      var visualTool = docViewer.getVisualToolById("AnnotationVisualTool,DocumentNavigationTool,TextSelectionTool,PanTool");
      // specify visual tool as mandatory visual tool of document viewer
      docViewer.set_MandatoryVisualTool(visualTool);
      // specify visual tool as current visual tool of document viewer
      docViewer.set_CurrentVisualTool(visualTool);
      
      // open file from session folder and add images from file to the image viewer
      docViewer.openFile("VintasoftImagingDemo.pdf");
      
      
  8. Запустите приложение ASP.NET Core и посмотрите результат.