Add web document viewer to a "Vue and ASP.NET Core" application
In This Topic
This tutorial shows how to create a blank "Vue and ASP.NET Core" application in Visual Studio .NET 2026 and add web document viewer (with ability to open images and documents (PDF, DOCX, XLSX), extract/search text, annotate documents) to "Vue and ASP.NET Core" application.
Here are steps, which must be done:
-
Create a blank "Vue and ASP.NET Core" application.
-
Open Visual Studio .NET 2026 and create a new application of "Vue and ASP.NET Core" type:
-
Configure the application to use .NET 10.0:
-
"VueApp1.Server" project: Add references to the Vintasoft nuget-packages to "VueApp1.Server" project.
Add references to the nuget-packages "Vintasoft.Imaging.Annotation.AspNetCore.ApiControllers", "Vintasoft.Imaging.Annotation.Pdf" and "Vintasoft.Imaging.Office.OpenXml" to the "VueApp1.Server" project. Other necessary nuget-packages will be added automatically.
-
"VueApp1.Server" project: Specify drawing engine, which should be used by VintaSoft Imaging .NET SDK for drawing of 2D graphics.
If "VueApp1.Server" project must be used in Windows or Linux, SkiaSharp drawing engine should be used.
If "VueApp1.Server" project must be used in Windows only, System.Drawing or SkiaSharp drawing engine should be used.
Here are steps, which should be made for using SkiaSharp engine:
-
Add reference to the "Vintasoft.Imaging.Drawing.SkiaSharp" nuget-package. Reference to the "SkiaSharp" nuget-package version 3.119.0 will be added automatically.
- Open "Program.cs" file in "VueApp1.Server" project, add code line "Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();" at the beginning of file - added code specifies that VintaSoft Imaging .NET SDK should use SkiaSharp library for drawing of 2D graphics.
Here are steps, which should be made for using System.Drawing engine:
-
Add reference to the "Vintasoft.Imaging.Gdi" nuget-package.
- Open "Program.cs" file in "VueApp1.Server" project, add code line "Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();" at the beginning of file - added code specifies that VintaSoft Imaging .NET SDK should use System.Drawing library for drawing of 2D graphics.
-
"VueApp1.Server" project: Create web services, which allow to upload/download file, manage image collection, get information about images, get thumbnails, render image tiles, extract/search text and annotate document.
-
Create web service that allows to upload/download file
-
Press the right mouse button on the "Controllers" folder and select the "Add => Controller..." menu from context menu
-
Select "Empty API controller" template, set the controller name to the "MyVintasoftFileApiController" and press the "Add" button
-
Specify that MyVintasoftFileApiController class is derived from Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController class
Here are source codes of MyVintasoftFileApiController class:
namespace VueApp1.Server.Controllers
{
public class MyVintasoftFileApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController
{
public MyVintasoftFileApiController(IWebHostEnvironment hostingEnvironment)
: base(hostingEnvironment)
{
}
}
}
-
Create web service that allows to manage image collection
-
Press the right mouse button on the "Controllers" folder and select the "Add => Controller..." menu from context menu
-
Select "Empty API controller" template, set the controller name to the "MyVintasoftImageCollectionApiController" and press the "Add" button
-
Specify that MyVintasoftImageCollectionApiController class is derived from Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageCollectionApiController class
Here are source codes of MyVintasoftImageCollectionApiController class:
namespace VueApp1.Server.Controllers
{
public class MyVintasoftImageCollectionApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageCollectionApiController
{
public MyVintasoftImageCollectionApiController(IWebHostEnvironment hostingEnvironment)
: base(hostingEnvironment)
{
}
}
}
-
Create web service that allows to get information about images, get thumbnails, render image tiles, extract/search text
-
Press the right mouse button on the "Controllers" folder and select the "Add => Controller..." menu from context menu
-
Select "Empty API controller" template, set the controller name to the "MyVintasoftImageApiController" and press the "Add" button
-
Specify that MyVintasoftImageApiController class is derived from Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageApiController class
Here are source codes of MyVintasoftImageApiController class:
namespace VueApp1.Server.Controllers
{
public class MyVintasoftImageApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageApiController
{
public MyVintasoftImageApiController(IWebHostEnvironment hostingEnvironment)
: base(hostingEnvironment)
{
}
}
}
-
Create web service that allows to annotate images and documents
-
Press the right mouse button on the "Controllers" folder and select the "Add => Controller..." menu from context menu
-
Select "Empty API controller" template, set the controller name to the "MyVintasoftAnnotationCollectionApiController" and press the "Add" button
-
Specify that MyVintasoftAnnotationCollectionApiController class is derived from Vintasoft.Imaging.Annotation.AspNetCore.ApiControllers.VintasoftAnnotationCollectionApiController class
Here are source codes of MyVintasoftAnnotationCollectionApiController class:
namespace VueApp1.Server.Controllers
{
public class MyVintasoftAnnotationCollectionApiController :
Vintasoft.Imaging.Annotation.AspNetCore.ApiControllers.VintasoftAnnotationCollectionApiController
{
public MyVintasoftAnnotationCollectionApiController(IWebHostEnvironment hostingEnvironment)
: base(hostingEnvironment)
{
}
}
}
-
"VueApp1.Server" project: Add Newtonsoft JSON for deserialization of JSON annotations.
- Add reference to the Microsoft.AspNetCore.Mvc.NewtonsoftJson nuget-package.
-
Open the "Program.cs" file in "VueApp1.Server" project and add code line "builder.Services.AddControllersWithViews().AddNewtonsoftJson();" after line "builder.Services.AddControllers();". This is necessary for correct deserialization of JSON annotations.
Here are source codes of "Program.cs" file after update:
Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddControllersWithViews().AddNewtonsoftJson();
var app = builder.Build();
app.UseDefaultFiles();
app.MapStaticAssets();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.MapFallbackToFile("/index.html");
app.Run();
-
"VueApp1.Server" project: Copy the default test PDF document to a server side.
- Create folder "UploadedImageFiles\SessionID" in "VueApp1.Server" project and copy test PDF document "<SdkInstallPath>\VintaSoft\Imaging .NET 15.0\Examples\ASP.NET Core\CSharp\AspNetCoreImagingDemo\wwwroot\UploadedImageFiles\VintasoftImagingDemo.pdf" to the folder. This document will be displayed in document viewer.
-
Delete files, which are not necessary in this tutorial.
-
Delete files "WeatherForecast.cs" and "Controllers\WeatherForecastController.cs" in "VueApp1.Server" project - the WeatherForecast Web API controller is not necessary in this tutorial.
-
Delete files "src\components\TheWelcome.vue", "src\components\WelcomeItem.vue" in "vueapp1.client" project - this Vue-component is not necessary in this tutorial.
-
Open file "src\App.vue" in "vueapp1.client" project and delete code that uses the following Vue-components: HelloWorld, TheWelcome - these Vue-components are not necessary in this tutorial.
Here are source codes of "App.vue" file after update:
<script setup>
</script>
<template>
<main>
</main>
</template>
<style scoped>
</style>
Compile the solution for restoring TypeScript-dependencies in "vueapp1.client" project.
-
"vueapp1.client" project: Add JavaScript files to the "vueapp1.client" project.
-
Copy files Vintasoft.Shared.js, Vintasoft.Imaging.js, Vintasoft.Imaging.Annotation.js and Vintasoft.Imaging.DocumentViewer.js from "<InstallPath>\VintaSoft Imaging .NET 15.0\Bin\JavaScript\" folder to the root folder of "vueapp1.client" project.
-
Copy files Vintasoft.Imaging.css and Vintasoft.Imaging.Annotation.css from "<InstallPath>\VintaSoft Imaging .NET 15.0\Bin\JavaScript\" folder to the root folder of "vueapp1.client" project.
-
Specify, which "standard" dialogs should be used by web document viewer
-
If web document viewer should use ready-to-use "standard" Bootstrap dialogs:
-
Add "bootstrap" Node-module to the "package.json" file. Rebuild the project for refreshing Node-modules.
Here are source codes of "package.json" file after update:
{
"name": "vueapp1.client",
"version": "0.0.0",
"private": true,
"type": "module",
"engines": {
"node": "^20.19.0 || >=22.12.0"
},
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --fix --cache"
},
"dependencies": {
"vue": "^3.5.26"
},
"devDependencies": {
"@eslint/js": "^9.39.2",
"@vitejs/plugin-vue": "^6.0.3",
"bootstrap": "~5.3.8",
"eslint": "^9.39.2",
"eslint-plugin-vue": "~10.6.2",
"globals": "^17.0.0",
"vite": "^7.3.0",
"vite-plugin-vue-devtools": "^8.0.5"
}
}
- Copy Vintasoft.Imaging.Dialogs.Bootstrap.js and Vintasoft.Imaging.DocumentViewer.Dialogs.Bootstrap.js files from "<InstallPath>\VintaSoft Imaging .NET 15.0\Bin\JavaScript\" folder to the root folder of "vueapp1.client" project.
-
If web document viewer should use ready-to-use "standard" jQuery UI dialogs:
- Add "jquery-ui-dist" Node-module to the "package.json" file. Rebuild the project for refreshing Node-modules.
- Copy Vintasoft.Imaging.Dialogs.jQueryUI.js and Vintasoft.Imaging.DocumentViewer.Dialogs.jQueryUI.js files from "<InstallPath>\VintaSoft Imaging .NET 15.0\Bin\JavaScript\" folder into "src\app\assets\" folder.
-
If web document viewer should use custom "standard" dialogs, please read how to create custom "standard" dialogs here.
-
Add references to Vintasoft JavaScript files to the header of "index.html" file in "vueapp1.client" project.
Add links to the Vintasoft CSS-files to the "index.html" file in "vueapp1.client" project.
Add link to the "bootstrap.css" file to the "index.html" file in "vueapp1.client" project.
Here are source codes of "index.html" file after update:
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="Vintasoft.Imaging.css">
<link rel="stylesheet" type="text/css" href="Vintasoft.Imaging.Annotation.css">
<script src="Vintasoft.Shared.js" type="text/javascript"></script>
<script src="Vintasoft.Imaging.js" type="text/javascript"></script>
<script src="Vintasoft.Imaging.Annotation.js" type="text/javascript"></script>
<script src="Vintasoft.Imaging.DocumentViewer.js" type="text/javascript"></script>
<script src="Vintasoft.Imaging.Dialogs.Bootstrap.js" type="text/javascript"></script>
<script src="Vintasoft.Imaging.Annotation.Dialogs.Bootstrap.js" type="text/javascript"></script>
<script src="Vintasoft.Imaging.DocumentViewer.Dialogs.Bootstrap.js" type="text/javascript"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
-
"vueapp1.client" project: Create Vue-component that allows to display document, search and extract text from document, annotate document.
-
In "vueapp1.client" project in folder "src\components\" create "DocumentViewerDemo.vue" file that will contain source codes of Vue-component:
- Select "Add => New Item..." context menu for folder "src\components\" in "vueapp1.client" project => "Add new item" dialog will appear
- Install template "Vue TypeScript Template" from internet if template is not installed in Visual Studio
- Select "Vue TypeScript Template" type for new item
- Set "DocumentViewerDemo.vue" as element name
- Click the "Add" button => dialog will be closed and file "DocumentViewerDemo.vue" will be added into folder "src\components\"
In DocumentViewerDemo.vue file add template that represents demo header and div-element that will display document viewer:
In DocumentViewerDemo.vue file change script type from TypeScript to JavaScript:
In DocumentViewerDemo.vue file add 'mounted' function (contains JavaScript code that initializes and creates web document viewer):
In DocumentViewerDemo.vue file add CSS-style for Vue-component:
Here is HTML/CSS/JavaScript code of DocumentViewerDemo Vue-component:
<template>
<h1>VintaSoft Document Viewer (ASP.NET Core + Vue)</h1>
<div id="documentViewerContainer" class="documentViewerContainer"></div>
</template>
<script lang="js">
import { defineComponent } from 'vue';
export default defineComponent({
mounted() {
setTimeout(__init, 500);
}
});
function __init() {
// 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("documentViewerContainer", { annotations: true });
// get items of document viewer
var items = docViewerSettings.get_Items();
// get the main menu of document viewer
var mainMenu = items.getItemByRegisteredId("mainMenu");
// if main menu is found
if (mainMenu != null) {
// get items of main menu
let mainMenuItems = mainMenu.get_Items();
// add "Annotation" menu panel to the main menu
mainMenuItems.addItem("annotationsMenuPanel");
}
// get side panel of document viewer
var sidePanel = items.getItemByRegisteredId("sidePanel");
// if side panel is found
if (sidePanel != null) {
// get items of side panel
let sidePanelItems = sidePanel.get_PanelsCollection();
// add "Annotations" panel to the side panel
sidePanelItems.addItem("annotationsPanel");
// add "Text selection" panel to the side panel
sidePanelItems.addItem("textSelectionPanel");
// add "Text searh" panel to the side panel
sidePanelItems.addItem("textSearchPanel");
}
// create the document viewer
var docViewer = new Vintasoft.Imaging.DocumentViewer.WebDocumentViewerJS(docViewerSettings);
// create visual tool that allows to work with annotations, navigate document and select text
var annotationNavigationTextSelectionTool =
docViewer.getVisualToolById("AnnotationVisualTool,DocumentNavigationTool,TextSelectionTool");
// specify visual tool as mandatory visual tool of document viewer
docViewer.set_MandatoryVisualTool(annotationNavigationTextSelectionTool);
// specify visual tool as current visual tool of document viewer
docViewer.set_CurrentVisualTool(annotationNavigationTextSelectionTool);
// get thumbnail viewer of document viewer
var thumbnailViewer = docViewer.get_ThumbnailViewer();
// specify that thumbnail viewer should not cache thumbnails on server side
thumbnailViewer.set_UseCache(false);
// get image viewer of document viewer
var imageViewer = docViewer.get_ImageViewer();
// specify that image viewer should not cache image tiles on server side
imageViewer.set_UseCache(false);
// open file from session folder and add images from file to the image viewer
imageViewer.get_Images().openFile("VintasoftImagingDemo.pdf");
}
</script>
<style scoped>
h1 {
width: 1200px;
text-align: center;
}
.documentViewerContainer {
width: 1200px;
height: 800px;
}
</style>
-
Add created Vue-component to the Vue-application code - "src\App.vue" file.
Here are source codes of "App.vue" file after update:
<script setup>
import DocumentViewerDemo from './components/DocumentViewerDemo.vue'
</script>
<template>
<main>
<DocumentViewerDemo />
</main>
</template>
<style scoped>
</style>
-
Open "vite.config.js" file in "vueapp1.client" project and specify that Vue.js aplication can have access to the ASP.NET Core Web API controller "/vintasoft/api/" in "VueApp1.Server" project:
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import plugin from '@vitejs/plugin-vue';
import fs from 'fs';
import path from 'path';
import child_process from 'child_process';
import { env } from 'process';
const baseFolder =
env.APPDATA !== undefined && env.APPDATA !== ''
? `${env.APPDATA}/ASP.NET/https`
: `${env.HOME}/.aspnet/https`;
const certificateName = "vueapp1.client";
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
if (!fs.existsSync(baseFolder)) {
fs.mkdirSync(baseFolder, { recursive: true });
}
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
if (0 !== child_process.spawnSync('dotnet', [
'dev-certs',
'https',
'--export-path',
certFilePath,
'--format',
'Pem',
'--no-password',
], { stdio: 'inherit', }).status) {
throw new Error("Could not create certificate.");
}
}
const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` :
env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'https://localhost:7140';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [plugin()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
'^/vintasoft/api/': {
target,
secure: false
}
},
port: parseInt(env.DEV_SERVER_PORT || '63870'),
https: {
key: fs.readFileSync(keyFilePath),
cert: fs.readFileSync(certFilePath),
}
}
})
-
Run the "Vue and ASP.NET Core" application and see the result.