-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SaravanaPriya31
authored and
SaravanaPriya31
committed
Mar 3, 2024
1 parent
40aa736
commit 8ce9fc4
Showing
19 changed files
with
530 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.10.34607.79 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFViewerSample", "PDFViewerSample\PDFViewerSample.csproj", "{3936B843-A035-424E-BA4B-990436AC60BD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3936B843-A035-424E-BA4B-990436AC60BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3936B843-A035-424E-BA4B-990436AC60BD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3936B843-A035-424E-BA4B-990436AC60BD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3936B843-A035-424E-BA4B-990436AC60BD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {31245B35-82FC-4C3B-A888-4730D0AD8EE0} | ||
EndGlobalSection | ||
EndGlobal |
13 changes: 13 additions & 0 deletions
13
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="24.2.8" /> | ||
</ItemGroup> | ||
|
||
</Project> |
6 changes: 6 additions & 0 deletions
6
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ActiveDebugProfile>https</ActiveDebugProfile> | ||
</PropertyGroup> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/Pages/Error.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@page | ||
@model ErrorModel | ||
@{ | ||
ViewData["Title"] = "Error"; | ||
} | ||
|
||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (Model.ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> |
28 changes: 28 additions & 0 deletions
28
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/Pages/Error.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using System.Diagnostics; | ||
|
||
namespace PDFViewerSample.Pages | ||
{ | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
[IgnoreAntiforgeryToken] | ||
public class ErrorModel : PageModel | ||
{ | ||
public string? RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
private readonly ILogger<ErrorModel> _logger; | ||
|
||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
|
||
} |
189 changes: 189 additions & 0 deletions
189
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
@page "{handler?}" | ||
@model IndexModel | ||
@{ | ||
ViewData["Title"] = "Home page"; | ||
} | ||
<tr> | ||
<td class="left-side-pdfviewer">Hide Default Context Menu</td> | ||
<td> | ||
<ejs-checkbox id="enable" cssClass="multiline" checked="false" change="contextmenuHelper"></ejs-checkbox> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="left-side-pdfviewer">Add Custom option at bottom</td> | ||
<td> | ||
<ejs-checkbox id="position" cssClass="multiline" checked="false" change="contextmenuHelper"></ejs-checkbox> | ||
</td> | ||
</tr> | ||
<div class="text-center"> | ||
<ejs-pdfviewer id="pdfviewer" style="height:600px" | ||
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" | ||
resourceUrl="https://cdn.syncfusion.com/ej2/24.1.41/dist/ej2-pdfviewer-lib" | ||
customContextMenuSelect="customContextMenuSelect" | ||
customContextMenuBeforeOpen="customContextMenuBeforeOpen" | ||
documentLoad="documentLoaded"> | ||
</ejs-pdfviewer> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
var menuItems = [ | ||
{ | ||
text: 'Search In Google', | ||
id: 'search_in_google', | ||
iconCss: 'e-icons e-de-ctnr-find' | ||
}, | ||
{ | ||
text: 'Lock Annotation', | ||
iconCss: 'e-icons e-lock', | ||
id: 'lock_annotation' | ||
}, | ||
{ | ||
text: 'Unlock Annotation', | ||
iconCss: 'e-icons e-unlock', | ||
id: 'unlock_annotation' | ||
}, | ||
{ | ||
text: 'Lock Form Fields', | ||
iconCss: 'e-icons e-lock', | ||
id: 'read_only_true' | ||
}, | ||
{ | ||
text: 'Unlock Form Fields', | ||
iconCss: 'e-icons e-unlock', | ||
id: 'read_only_false' | ||
}, | ||
]; | ||
function documentLoaded(arg) { | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
pdfviewer.addCustomMenu(menuItems, false, false); | ||
} | ||
function customContextMenuSelect(args) { | ||
switch (args.id) { | ||
case 'search_in_google': | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
for (var i = 0; i < pdfviewer.textSelectionModule.selectionRangeArray.length; i++) { | ||
var content = pdfviewer.textSelectionModule.selectionRangeArray[i].textContent; | ||
if ((pdfviewer.textSelectionModule.isTextSelection) && (/\S/.test(content))) { | ||
window.open('http://google.com/search?q=' + content); | ||
} | ||
} | ||
break; | ||
case 'lock_annotation': | ||
lockAnnotations(args); | ||
break; | ||
case 'unlock_annotation': | ||
unlockAnnotations(args); | ||
break; | ||
case 'read_only_true': | ||
setReadOnlyTrue(args); | ||
break; | ||
case 'read_only_false': | ||
setReadOnlyFalse(args); | ||
break; | ||
case 'formfield properties': | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
function customContextMenuBeforeOpen(args) { | ||
for (var i = 0; i < args.ids.length; i++) { | ||
var search = document.getElementById(args.ids[i]); | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
search.style.display = 'none'; | ||
if (search) { | ||
search.style.display = 'none'; | ||
if (args.ids[i] === 'search_in_google' && (pdfviewer.textSelectionModule) && pdfviewer.textSelectionModule.isTextSelection) { | ||
search.style.display = 'block'; | ||
} else if (args.ids[i] === "lock_annotation" || args.ids[i] === "unlock_annotation") { | ||
var isLockOption = args.ids[i] === "lock_annotation"; | ||
for (var j = 0; j < pdfviewer.selectedItems.annotations.length; j++) { | ||
var selectedAnnotation = pdfviewer.selectedItems.annotations[j]; | ||
if (selectedAnnotation && selectedAnnotation.annotationSettings) { | ||
var shouldDisplay = (isLockOption && !selectedAnnotation.annotationSettings.isLock) || | ||
(!isLockOption && selectedAnnotation.annotationSettings.isLock); | ||
search.style.display = shouldDisplay ? 'block' : 'none'; | ||
} | ||
} | ||
} else if ((args.ids[i] === "read_only_true" || args.ids[i] === "read_only_false") && pdfviewer.selectedItems.formFields.length !== 0) { | ||
var isReadOnlyOption = args.ids[i] === "read_only_true"; | ||
for (var j = 0; j < pdfviewer.selectedItems.formFields.length; j++) { | ||
var selectedFormFields = pdfviewer.selectedItems.formFields[j]; | ||
if (selectedFormFields) { | ||
var selectedFormField = pdfviewer.selectedItems.formFields[j].isReadonly; | ||
var displayMenu = (isReadOnlyOption && !selectedFormField) || (!isReadOnlyOption && selectedFormField); | ||
search.style.display = displayMenu ? 'block' : 'none'; | ||
} | ||
} | ||
} else if (args.ids[i] === 'formfield properties' && pdfviewer.selectedItems.formFields.length !== 0) { | ||
search.style.display = 'block'; | ||
} | ||
} | ||
} | ||
}; | ||
function lockAnnotations(args) { | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
var selectedAnnotations = pdfviewer.selectedItems.annotations; | ||
for (var i = 0; i < selectedAnnotations.length; i++) { | ||
var annotation = selectedAnnotations[i]; | ||
if (annotation && annotation.annotationSettings) { | ||
annotation.annotationSettings.isLock = true; | ||
pdfviewer.annotationModule.editAnnotation(annotation); | ||
args.cancel = false; | ||
} | ||
} | ||
} | ||
function unlockAnnotations(args) { | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
var selectedAnnotations = pdfviewer.selectedItems.annotations; | ||
for (var i = 0; i < selectedAnnotations.length; i++) { | ||
var annotation = selectedAnnotations[i]; | ||
if (annotation && annotation.annotationSettings) { | ||
annotation.annotationSettings.isLock = false; | ||
pdfviewer.annotationModule.editAnnotation(annotation); | ||
args.cancel = false; | ||
} | ||
} | ||
} | ||
function setReadOnlyTrue(args) { | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
var selectedFormFields = pdfviewer.selectedItems.formFields; | ||
for (var i = 0; i < selectedFormFields.length; i++) { | ||
var selectedFormField = selectedFormFields[i]; | ||
if (selectedFormField) { | ||
pdfviewer.formDesignerModule.updateFormField(selectedFormField, { | ||
isReadOnly: true, | ||
}); | ||
} | ||
args.cancel = false; | ||
} | ||
} | ||
function setReadOnlyFalse(args) { | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
var selectedFormFields = pdfviewer.selectedItems.formFields; | ||
for (var i = 0; i < selectedFormFields.length; i++) { | ||
var selectedFormField = selectedFormFields[i]; | ||
if (selectedFormField) { | ||
pdfviewer.formDesignerModule.updateFormField(selectedFormField, { | ||
isReadOnly: false, | ||
}); | ||
} | ||
args.cancel = false; | ||
} | ||
} | ||
function contextmenuHelper(args) { | ||
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]; | ||
pdfviewer.addCustomMenu(menuItems, enable.checked, position.checked); | ||
} | ||
</script> |
20 changes: 20 additions & 0 deletions
20
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace PDFViewerSample.Pages | ||
{ | ||
public class IndexModel : PageModel | ||
{ | ||
private readonly ILogger<IndexModel> _logger; | ||
|
||
public IndexModel(ILogger<IndexModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
|
||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/Pages/Privacy.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@page | ||
@model PrivacyModel | ||
@{ | ||
ViewData["Title"] = "Privacy Policy"; | ||
} | ||
<h1>@ViewData["Title"]</h1> | ||
|
||
<p>Use this page to detail your site's privacy policy.</p> |
20 changes: 20 additions & 0 deletions
20
How to/Custom Context Menu/PDFViewerSample/PDFViewerSample/Pages/Privacy.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace PDFViewerSample.Pages | ||
{ | ||
public class PrivacyModel : PageModel | ||
{ | ||
private readonly ILogger<PrivacyModel> _logger; | ||
|
||
public PrivacyModel(ILogger<PrivacyModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.