Skip to content

Commit

Permalink
834567: Sample on How to Add Rectangle Annotations Using Search Text …
Browse files Browse the repository at this point in the history
…Bounds
  • Loading branch information
SF4524LogeshKumar committed Dec 16, 2024
1 parent 6404d87 commit e13826f
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import {
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService
} from '@syncfusion/ej2-angular-pdfviewer';

@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<div style="margin-top: 20px;">
<button (click)="handleSearch()">Search PDF</button>
<button (click)="handleSearchNext()">Search Next</button>
<button (click)="handleCancelSearch()">Cancel Search</button>
</div>
<ejs-pdfviewer #pdfViewer
id="pdfViewer"
[documentPath]='document'
[resourceUrl]='resource'
style="height:640px;display:block"
(textSearchHighlight)="handleTextSearchHighlight($event)">
</ejs-pdfviewer>
</div>
`,
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService
]
})
export class AppComponent implements OnInit {
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string = 'https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib';
pdfViewerComponent: any;

ngOnInit(): void {
}

handleSearch() {
var pdfviewer = (<any>document.getElementById("pdfViewer")).ej2_instances[0];
pdfviewer.textSearchModule.searchText('PDF', false);
}

handleSearchNext() {
var pdfviewer = (<any>document.getElementById("pdfViewer")).ej2_instances[0];
pdfviewer.textSearchModule.searchNext();
}

handleCancelSearch() {
var pdfviewer = (<any>document.getElementById("pdfViewer")).ej2_instances[0];
pdfviewer.textSearchModule.cancelTextSearch();
}

handleTextSearchHighlight(args: any) {
var pdfviewer = (<any>document.getElementById("pdfViewer")).ej2_instances[0];
console.log(args);
const bounds = args.bounds;
pdfviewer.annotationModule.addAnnotation('Rectangle', {
pageNumber: args.pageNumber,
offset: { x: bounds.left, y: bounds.top },
width: bounds.width,
height: bounds.height,
});
}
}
51 changes: 0 additions & 51 deletions How to/Get co-ordinates of Annotations/src/app/app.component.ts

This file was deleted.

0 comments on commit e13826f

Please sign in to comment.