Skip to content

Commit 96a577a

Browse files
authored
Merge pull request #50 from SyncfusionExamples/EJ2-845073-shAnnot
845073: Sample to show and Hide Annotations
2 parents 8917e64 + fd39687 commit 96a577a

21 files changed

+378
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.10.34607.79
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShowHideAnnotations", "ShowHideAnnotations\ShowHideAnnotations.csproj", "{AEF9913F-0F38-4676-9A9F-D1042B5C30AC}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{AEF9913F-0F38-4676-9A9F-D1042B5C30AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AEF9913F-0F38-4676-9A9F-D1042B5C30AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AEF9913F-0F38-4676-9A9F-D1042B5C30AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AEF9913F-0F38-4676-9A9F-D1042B5C30AC}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {31245B35-82FC-4C3B-A888-4730D0AD8EE0}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6+
<add key="nexus" value="https://nexus.syncfusioninternal.com/repository/nuget-hosted/" />
7+
</packageSources>
8+
<disabledPackageSources>
9+
<clear />
10+
</disabledPackageSources>
11+
<fallbackPackageFolders>
12+
<clear />
13+
</fallbackPackageFolders>
14+
</configuration>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Diagnostics;
4+
5+
namespace PDFViewerSample.Pages
6+
{
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+
28+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@page "{handler?}"
2+
@using ShowHideAnnotations.Pages
3+
@model IndexModel
4+
@{
5+
ViewData["Title"] = "Home page";
6+
}
7+
8+
<div class="text-center">
9+
<button id="hideBtn">Hide Annotations</button>
10+
<button id="unhideBtn">Show Annotations</button>
11+
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl="https://cdn.syncfusion.com/ej2/30.1.37/dist/ej2-pdfviewer-lib" documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
12+
</ejs-pdfviewer>
13+
</div>
14+
15+
<script type="text/javascript">
16+
var exportObject = null;
17+
18+
document.addEventListener('DOMContentLoaded', function() {
19+
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0];
20+
21+
function HideAnnotations() {
22+
pdfviewer.exportAnnotationsAsObject().then(function(value) {
23+
exportObject = value;
24+
pdfviewer.deleteAnnotations();
25+
});
26+
}
27+
28+
function UnHideAnnotations() {
29+
if (exportObject) {
30+
pdfviewer.importAnnotation(JSON.parse(exportObject));
31+
}
32+
}
33+
34+
document.getElementById('hideBtn').addEventListener('click', HideAnnotations);
35+
document.getElementById('unhideBtn').addEventListener('click', UnHideAnnotations);
36+
});
37+
</script>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.Extensions.Caching.Memory;
3+
using Syncfusion.EJ2.PdfViewer;
4+
using Newtonsoft.Json;
5+
using Microsoft.AspNetCore.Mvc.RazorPages;
6+
using System.Reflection;
7+
using System.Net;
8+
using Syncfusion.Pdf.Parsing;
9+
10+
namespace ShowHideAnnotations.Pages
11+
{
12+
[IgnoreAntiforgeryToken(Order = 1001)]
13+
public class IndexModel : PageModel
14+
{
15+
16+
private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
17+
private IMemoryCache _cache;
18+
19+
public IndexModel(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment, IMemoryCache cache)
20+
{
21+
_hostingEnvironment = hostingEnvironment;
22+
_cache = cache;
23+
}
24+
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model PrivacyModel
3+
@{
4+
ViewData["Title"] = "Privacy Policy";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>Use this page to detail your site's privacy policy.</p>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
4+
namespace PDFViewerSample.Pages
5+
{
6+
public class PrivacyModel : PageModel
7+
{
8+
private readonly ILogger<PrivacyModel> _logger;
9+
10+
public PrivacyModel(ILogger<PrivacyModel> logger)
11+
{
12+
_logger = logger;
13+
}
14+
15+
public void OnGet()
16+
{
17+
}
18+
}
19+
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - PDFViewerSample</title>
7+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
8+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
9+
<link rel="stylesheet" href="~/PDFViewerSample.styles.css" asp-append-version="true" />
10+
<!-- Syncfusion ASP.NET Core controls styles -->
11+
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/30.1.37/fluent.css" />
12+
<!-- Syncfusion ASP.NET Core controls scripts -->
13+
<script src="https://cdn.syncfusion.com/ej2/30.1.37/dist/ej2.min.js"></script>
14+
</head>
15+
<body>
16+
<div class="container">
17+
<main role="main" class="pb-3">
18+
@RenderBody()
19+
</main>
20+
</div>
21+
22+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
23+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
24+
<script src="~/js/site.js" asp-append-version="true"></script>
25+
26+
@await RenderSectionAsync("Scripts", required: false)
27+
<!-- Syncfusion ASP.NET Core Script Manager -->
28+
<ejs-scripts></ejs-scripts>
29+
</body>
30+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
2+
for details on configuring this project to bundle and minify static web assets. */
3+
4+
a.navbar-brand {
5+
white-space: normal;
6+
text-align: center;
7+
word-break: break-all;
8+
}
9+
10+
a {
11+
color: #0077cc;
12+
}
13+
14+
.btn-primary {
15+
color: #fff;
16+
background-color: #1b6ec2;
17+
border-color: #1861ac;
18+
}
19+
20+
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21+
color: #fff;
22+
background-color: #1b6ec2;
23+
border-color: #1861ac;
24+
}
25+
26+
.border-top {
27+
border-top: 1px solid #e5e5e5;
28+
}
29+
.border-bottom {
30+
border-bottom: 1px solid #e5e5e5;
31+
}
32+
33+
.box-shadow {
34+
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35+
}
36+
37+
button.accept-policy {
38+
font-size: 1rem;
39+
line-height: inherit;
40+
}
41+
42+
.footer {
43+
position: absolute;
44+
bottom: 0;
45+
width: 100%;
46+
white-space: nowrap;
47+
line-height: 60px;
48+
}

0 commit comments

Comments
 (0)