-
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.
Merge pull request #37 from SyncfusionExamples/EJ2-834567-getCoordinates
834567: How to Add Rectangle Annotations Using Search Text Bounds
- Loading branch information
Showing
20 changed files
with
381 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ions Using Search Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch.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}") = "AddRectangleUsingTextSearch", "AddRectangleUsingTextSearch\AddRectangleUsingTextSearch.csproj", "{9E1F3D8A-48BD-40BA-89B8-1A9D66BB82C3}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9E1F3D8A-48BD-40BA-89B8-1A9D66BB82C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9E1F3D8A-48BD-40BA-89B8-1A9D66BB82C3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9E1F3D8A-48BD-40BA-89B8-1A9D66BB82C3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9E1F3D8A-48BD-40BA-89B8-1A9D66BB82C3}.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
...ddRectangleUsingTextSearch/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch.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="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
6 changes: 6 additions & 0 deletions
6
...tangleUsingTextSearch/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch.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> |
9 changes: 9 additions & 0 deletions
9
.../AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch.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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ActiveDebugProfile>IIS Express</ActiveDebugProfile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
...ch Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/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
...Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/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; | ||
} | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...ch Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/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,58 @@ | ||
@page "{handler?}" | ||
@model IndexModel | ||
@{ | ||
ViewData["Title"] = "Home page"; | ||
} | ||
<div class="text-center"> | ||
<!-- Control buttons for PDF Search functionality --> | ||
<div style="margin-top: 20px;"> | ||
<button onclick="handleSearch()">Search PDF</button> | ||
<button onclick="handleSearchNext()">Search Next</button> | ||
<button onclick="handleCancelSearch()">Cancel Search</button> | ||
</div> | ||
<ejs-pdfviewer id="pdfviewer" style="height:600px" | ||
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" | ||
resourceUrl="https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib" | ||
textSearchHighlight="handleTextSearchHighlight"> | ||
</ejs-pdfviewer> | ||
</div> | ||
<script type="text/javascript"> | ||
// Function to get the PDF Viewer instance | ||
function getPdfViewerInstance() { | ||
return document.getElementById('pdfviewer').ej2_instances[0]; | ||
} | ||
// Initiates a search for the term 'PDF' in the document | ||
function handleSearch() { | ||
const pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.textSearchModule.searchText('PDF', false); | ||
} | ||
// Searches for the next occurrence of the term | ||
function handleSearchNext() { | ||
const pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.textSearchModule.searchNext(); | ||
} | ||
// Cancels the current text search operation | ||
function handleCancelSearch() { | ||
const pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.textSearchModule.cancelTextSearch(); | ||
} | ||
// Event handler for annotation addition | ||
// Adds a rectangle annotation around highlighted text | ||
function handleTextSearchHighlight(args) { | ||
console.log(args); // Log details of the added annotation around highlighted text | ||
const pdfViewer = getPdfViewerInstance(); | ||
const bounds = args.bounds; | ||
pdfViewer.annotationModule.addAnnotation('Rectangle', { | ||
pageNumber: args.pageNumber, | ||
offset: { x: bounds.left, y: bounds.top }, | ||
width: bounds.width, | ||
height: bounds.height, | ||
}); | ||
} | ||
</script> |
20 changes: 20 additions & 0 deletions
20
...Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/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
... Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/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
...xt Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/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() | ||
{ | ||
} | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...ounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/Pages/Shared/_Layout.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,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>@ViewData["Title"] - PDFViewerSample</title> | ||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> | ||
<link rel="stylesheet" href="~/PDFViewerSample.styles.css" asp-append-version="true" /> | ||
<!-- Syncfusion ASP.NET Core controls styles --> | ||
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/27.1.48/fluent.css" /> | ||
<!-- Syncfusion ASP.NET Core controls scripts --> | ||
<script src="https://cdn.syncfusion.com/ej2/27.1.48/dist/ej2.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<main role="main" class="pb-3"> | ||
@RenderBody() | ||
</main> | ||
</div> | ||
|
||
<script src="~/lib/jquery/dist/jquery.min.js"></script> | ||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> | ||
<script src="~/js/site.js" asp-append-version="true"></script> | ||
|
||
@await RenderSectionAsync("Scripts", required: false) | ||
<!-- Syncfusion ASP.NET Core Script Manager --> | ||
<ejs-scripts></ejs-scripts> | ||
</body> | ||
</html> |
48 changes: 48 additions & 0 deletions
48
...s/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/Pages/Shared/_Layout.cshtml.css
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,48 @@ | ||
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification | ||
for details on configuring this project to bundle and minify static web assets. */ | ||
|
||
a.navbar-brand { | ||
white-space: normal; | ||
text-align: center; | ||
word-break: break-all; | ||
} | ||
|
||
a { | ||
color: #0077cc; | ||
} | ||
|
||
.btn-primary { | ||
color: #fff; | ||
background-color: #1b6ec2; | ||
border-color: #1861ac; | ||
} | ||
|
||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { | ||
color: #fff; | ||
background-color: #1b6ec2; | ||
border-color: #1861ac; | ||
} | ||
|
||
.border-top { | ||
border-top: 1px solid #e5e5e5; | ||
} | ||
.border-bottom { | ||
border-bottom: 1px solid #e5e5e5; | ||
} | ||
|
||
.box-shadow { | ||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); | ||
} | ||
|
||
button.accept-policy { | ||
font-size: 1rem; | ||
line-height: inherit; | ||
} | ||
|
||
.footer { | ||
position: absolute; | ||
bottom: 0; | ||
width: 100%; | ||
white-space: nowrap; | ||
line-height: 60px; | ||
} |
2 changes: 2 additions & 0 deletions
2
...UsingTextSearch/AddRectangleUsingTextSearch/Pages/Shared/_ValidationScriptsPartial.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,2 @@ | ||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script> | ||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script> |
4 changes: 4 additions & 0 deletions
4
... Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/Pages/_ViewImports.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,4 @@ | ||
@using PDFViewerSample | ||
@namespace PDFViewerSample.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@addTagHelper *, Syncfusion.EJ2 |
3 changes: 3 additions & 0 deletions
3
...xt Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/Pages/_ViewStart.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,3 @@ | ||
@{ | ||
Layout = "_Layout"; | ||
} |
25 changes: 25 additions & 0 deletions
25
...ing Search Text Bounds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/Program.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,25 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
builder.Services.AddRazorPages(); | ||
|
||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (!app.Environment.IsDevelopment()) | ||
{ | ||
app.UseExceptionHandler("/Error"); | ||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | ||
app.UseHsts(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
app.UseStaticFiles(); | ||
|
||
app.UseRouting(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapRazorPages(); | ||
|
||
app.Run(); |
38 changes: 38 additions & 0 deletions
38
...ds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/Properties/launchSettings.json
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,38 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:12333", | ||
"sslPort": 44366 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5059", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:7232;http://localhost:5059", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...unds/AddRectangleUsingTextSearch/AddRectangleUsingTextSearch/appsettings.Development.json
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,9 @@ | ||
{ | ||
"DetailedErrors": true, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
Oops, something went wrong.