Skip to content

Commit d5aad0e

Browse files
966016: Sample on How to Dynamically enable or disable Text Selection
1 parent b0ce363 commit d5aad0e

File tree

80 files changed

+83039
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+83039
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfViewerApp", "PdfViewerApp\PdfViewerApp.csproj", "{C9CC25B9-30AB-08BE-C969-C8B6D4A156D7}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{C9CC25B9-30AB-08BE-C969-C8B6D4A156D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{C9CC25B9-30AB-08BE-C969-C8B6D4A156D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{C9CC25B9-30AB-08BE-C969-C8B6D4A156D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{C9CC25B9-30AB-08BE-C969-C8B6D4A156D7}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {BFFAA0D9-4F91-4FF6-B8DD-05C07AE23993}
23+
EndGlobalSection
24+
EndGlobal
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Diagnostics;
2+
using Microsoft.AspNetCore.Mvc;
3+
using PdfViewerApp.Models;
4+
5+
namespace PdfViewerApp.Controllers;
6+
7+
public class HomeController : Controller
8+
{
9+
private readonly ILogger<HomeController> _logger;
10+
11+
public HomeController(ILogger<HomeController> logger)
12+
{
13+
_logger = logger;
14+
}
15+
16+
public IActionResult Index()
17+
{
18+
return View();
19+
}
20+
21+
public IActionResult Privacy()
22+
{
23+
return View();
24+
}
25+
26+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
27+
public IActionResult Error()
28+
{
29+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
30+
}
31+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace PdfViewerApp.Models;
2+
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="29.2.11" />
11+
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="29.2.11" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
builder.Services.AddControllersWithViews();
7+
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
8+
9+
10+
var app = builder.Build();
11+
12+
// Configure the HTTP request pipeline.
13+
if (!app.Environment.IsDevelopment())
14+
{
15+
app.UseExceptionHandler("/Home/Error");
16+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
17+
app.UseHsts();
18+
}
19+
20+
app.UseHttpsRedirection();
21+
app.UseRouting();
22+
23+
app.UseAuthorization();
24+
25+
app.MapStaticAssets();
26+
27+
app.MapControllerRoute(
28+
name: "default",
29+
pattern: "{controller=Home}/{action=Index}/{id?}")
30+
.WithStaticAssets();
31+
32+
33+
app.Run();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:5257",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": true,
17+
"applicationUrl": "https://localhost:7060;http://localhost:5257",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@using Syncfusion.EJ2
2+
@{
3+
ViewBag.Title = "Home Page";
4+
}
5+
6+
<div>
7+
<div style="height:500px;width:100%;">
8+
<button onclick="enableTextSelection()">EnableTextSelection</button>
9+
<button onclick="disableTextSelection()">DisableTextSelection</button>
10+
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf").ResourceUrl("https://cdn.syncfusion.com/ej2/30.1.37/dist/ej2-pdfviewer-lib").EnableTextSelection(false).Render();
11+
</div>
12+
</div>
13+
<script type="text/javascript">
14+
function enableTextSelection()
15+
{
16+
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
17+
viewer.enableTextSelection=true;
18+
}
19+
function disableTextSelection()
20+
{
21+
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
22+
viewer.enableTextSelection=false;
23+
}
24+
</script>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
ViewData["Title"] = "Privacy Policy";
3+
}
4+
<h1>@ViewData["Title"]</h1>
5+
6+
<p>Use this page to detail your site's privacy policy.</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@model ErrorViewModel
2+
@{
3+
ViewData["Title"] = "Error";
4+
}
5+
6+
<h1 class="text-danger">Error.</h1>
7+
<h2 class="text-danger">An error occurred while processing your request.</h2>
8+
9+
@if (Model.ShowRequestId)
10+
{
11+
<p>
12+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
13+
</p>
14+
}
15+
16+
<h3>Development Mode</h3>
17+
<p>
18+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
19+
</p>
20+
<p>
21+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22+
It can result in displaying sensitive information from exceptions to end users.
23+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
24+
and restarting the app.
25+
</p>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@using Syncfusion.EJ2
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>@ViewData["Title"] - PdfViewerApp</title>
8+
<script type="importmap"></script>
9+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
10+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
11+
<link rel="stylesheet" href="~/PdfViewerApp.styles.css" asp-append-version="true" />
12+
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/29.1.33/fluent.css" />
13+
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js"></script>
14+
</head>
15+
<body>
16+
<header>
17+
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
18+
<div class="container-fluid">
19+
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">PdfViewerApp</a>
20+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
21+
aria-expanded="false" aria-label="Toggle navigation">
22+
<span class="navbar-toggler-icon"></span>
23+
</button>
24+
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
25+
<ul class="navbar-nav flex-grow-1">
26+
<li class="nav-item">
27+
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
28+
</li>
29+
<li class="nav-item">
30+
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
31+
</li>
32+
</ul>
33+
</div>
34+
</div>
35+
</nav>
36+
</header>
37+
<div class="container">
38+
<main role="main" class="pb-3">
39+
@RenderBody()
40+
</main>
41+
</div>
42+
43+
<footer class="border-top footer text-muted">
44+
<div class="container">
45+
&copy; 2025 - PdfViewerApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
46+
</div>
47+
</footer>
48+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
49+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
50+
<script src="~/js/site.js" asp-append-version="true"></script>
51+
@await RenderSectionAsync("Scripts", required: false)
52+
@Html.EJS().ScriptManager()
53+
</body>
54+
</html>

0 commit comments

Comments
 (0)