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

HTML-страница может содержать ссылки на внешние ресурсы (CSS-файлы, файлы изображений и т. д.). По умолчанию VintaSoft веб просмотрщик не позволяет загружать внешние ресурсы по соображениям безопасности, то есть VintaSoft веб просмотрщик отображает HTML-страницу без внешних CSS-стилей и изображений.
Вот скриншот VintaSoft веб просмотрщика документов с HTML-страницей (https://www.vintasoft.ru/index.html), которая отображается без внешних CSS-стилей и изображений:


VintaSoft веб просмотрщик позволяет включить загрузку внешних ресурсов, то есть отображать HTML-страницу с внешними CSS-стилями и изображениями.
Вот скриншот VintaSoft веб просмотрщика документов с HTML-страницей (https://www.vintasoft.ru/index.html), которая отображается с использованием CSS-стилей и изображений:



Если необходимо разрешить загрузку всех внешних ресурсов, следует выполнить следующие шаги:
Вот C# код, который демонстрирует как включить загрузку всех внешних ресурсов в VintaSoft веб просмотрщике документов:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Vintasoft.Imaging;

namespace AspNetCoreDocumentViewerDemo
{
    public class Startup
    {

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }



        public IConfiguration Configuration { get; }



        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // set the custom font program controller as the default font program controller
            CustomFontProgramsController.SetDefaultFontProgramsController();

            // specify that VintaSoft Imaging .NET SDK should use SkiaSharp library for drawing of 2D graphics
            Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

            // specify that VintaSoft image web service can access the external resources
            Vintasoft.Imaging.Web.Services.VintasoftImageWebService.AllowAccessToExternalResources = true;

            services.AddControllersWithViews().AddNewtonsoftJson();
            services.AddSession();
        }
...


Если необходимо включить загрузку внешних ресурсов и управлять доступом к ним, следует выполнить следующие шаги:
Вот C# код, который демонстрирует как включить загрузку внешних ресурсов в VintaSoft веб просмотрщике документов и разрешить доступ к внешним ресурсам только по адресу "https://www.vintasoft.ru":
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Vintasoft.Imaging;

namespace AspNetCoreDocumentViewerDemo
{
    public class Startup
    {

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }



        public IConfiguration Configuration { get; }



        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // set the custom font program controller as the default font program controller
            CustomFontProgramsController.SetDefaultFontProgramsController();

            // specify that VintaSoft Imaging .NET SDK should use SkiaSharp library for drawing of 2D graphics
            Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

            // specify that VintaSoft image web service can access the external resources
            Vintasoft.Imaging.Web.Services.VintasoftImageWebService.AllowAccessToExternalResources = true;
            // subscribe to the ExternalResourceManager.VerifyResourceAccess event to manage access to the external resources
            ImagingEnvironment.ExternalResourceManager.VerifyResourceAccess += ExternalResourceManager_VerifyResourceAccess;

            services.AddControllersWithViews().AddNewtonsoftJson();
            services.AddSession();
        }

        private void ExternalResourceManager_VerifyResourceAccess(object sender, ExternalResourceVerifyAccessEventArgs e)
        {
            e.IsAccessAllowed = false;
            if (e.Uri.ToString().StartsWith("https://www.vintasoft.com"))
                e.IsAccessAllowed = true;
        }
...