-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.component.ts
More file actions
71 lines (60 loc) · 2.7 KB
/
Copy pathapp.component.ts
File metadata and controls
71 lines (60 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Component, ViewEncapsulation, OnInit,ViewChild} from '@angular/core';
import { PdfViewerComponent, LinkAnnotationService, BookmarkViewService, MagnificationService, ThumbnailViewService, ToolbarService, NavigationService, TextSearchService, TextSelectionService, PrintService, AnnotationService, FormFieldsService, FormDesignerService, PageOrganizerService,PdfViewerModule, TextSelectionStartEventArgs, AnnotationSelectEventArgs, StickyNotesSettings } from '@syncfusion/ej2-angular-pdfviewer';
import { SwitchComponent, SwitchModule } from '@syncfusion/ej2-angular-buttons';
import { ClickEventArgs } from '@syncfusion/ej2-buttons';
/**
* Default PdfViewer Controller
*/
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
encapsulation: ViewEncapsulation.None,
// tslint:disable-next-line:max-line-length
providers: [LinkAnnotationService, BookmarkViewService, MagnificationService, ThumbnailViewService, ToolbarService, NavigationService,
TextSearchService, TextSelectionService, PrintService, AnnotationService, FormFieldsService, FormDesignerService,PageOrganizerService],
styleUrls: ['app.component.css'],
standalone: true,
imports: [
SwitchModule,
PdfViewerModule,
],
})
export class AppComponent {
@ViewChild('pdfviewer')
public pdfviewer: PdfViewerComponent | undefined;
// PDF document and resource URLs
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string = 'https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib';
ngOnInit(): void {
// ngOnInit function
}
public annotationAdded = true;
// Add Sticky Note annotation when the document is loaded
documentLoad() {
this.pdfviewer?.annotation.addAnnotation('StickyNotes', {
offset: { x: 20, y: 20 }, // Position of the annotation
author: 'Syncfusion',
pageNumber: this.pdfviewer.currentPageNumber,
subject: 'Sticky Note',
isLock: false,
} as StickyNotesSettings);
}
// Add comment to the newly added Sticky Note annotation
annotationAdd() {
if (this.annotationAdded) {
setTimeout(() => {
// Get the last added annotation
const addedAnnotation = this.pdfviewer?.annotationCollection[
this.pdfviewer.annotationCollection.length - 1
];
// Set the comment text
addedAnnotation.note = 'text';
// Update the annotation with the new comment
this.pdfviewer?.annotation.editAnnotation(addedAnnotation);
console.log(this.pdfviewer?.annotationCollection);
}, 200);
// Prevent duplicate comment addition
this.annotationAdded = false;
}
}
}