-
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.
834567: How toAdd Rectangle Annotations Using Search Text Bounds
- Loading branch information
1 parent
cd74989
commit 3479f3c
Showing
27 changed files
with
69 additions
and
22 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions
64
...otations Using Search Text Bounds/WebApplication1/WebApplication1/Views/Home/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,64 @@ | ||
@using Syncfusion.EJ2 | ||
@{ | ||
ViewBag.Title = "Home Page"; | ||
} | ||
<!-- 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> | ||
<div> | ||
<!-- Render PDF Viewer using the Html helper method --> | ||
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf").TextSearchHighlight("handleTextSearchHighlight").Render() | ||
</div> | ||
|
||
|
||
<script type="text/javascript"> | ||
window.onload = function () { | ||
// Access the PDF Viewer instance on page load | ||
var pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.enableLocalStorage = true; // Enable or configure as needed | ||
}; | ||
// Function to get the PDF Viewer instance conveniently | ||
function getPdfViewerInstance() { | ||
return document.getElementById('pdfviewer').ej2_instances[0]; | ||
} | ||
// Initiate search for the term 'PDF' in the document | ||
function handleSearch() { | ||
const pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.textSearchModule.searchText('PDF', false); | ||
} | ||
// Move to next search result | ||
function handleSearchNext() { | ||
const pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.textSearchModule.searchNext(); | ||
} | ||
// Cancel any ongoing text search operation | ||
function handleCancelSearch() { | ||
const pdfViewer = getPdfViewerInstance(); | ||
pdfViewer.textSearchModule.cancelTextSearch(); | ||
} | ||
// Event handler for when text is highlighted during search | ||
function handleTextSearchHighlight(args) { | ||
const pdfViewer = getPdfViewerInstance(); | ||
console.log(args); // Display highlight event data | ||
const bounds = args.bounds; | ||
// Add rectangle annotation around highlighted text | ||
pdfViewer.annotationModule.addAnnotation('Rectangle', { | ||
pageNumber: args.pageNumber, | ||
offset: { x: bounds.left, y: bounds.top }, | ||
width: bounds.width, | ||
height: bounds.height, | ||
strokeColor: "red", // Customize the stroke color if desired | ||
borderWidth: 2 | ||
}); | ||
} | ||
</script> |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
17 changes: 0 additions & 17 deletions
17
...o/Get co-ordinates of Annotations/WebApplication1/WebApplication1/Views/Home/Index.cshtml
This file was deleted.
Oops, something went wrong.