How can I help you?
Print events in Angular PDF Viewer
13 Apr 20265 minutes to read
This page lists each event emitted by the Angular PDF Viewer’s Print feature, the argument schema, and the minimal behavior notes needed for implementation.
Events
| Name | Description |
|---|---|
printStart |
Raised when a print action begins. Use the event to log activity or cancel printing. |
printEnd |
Raised after a print action completes. Use the event to notify users or clean up resources. |
printStart
This event is emitted when printing is initiated by toolbar or through programmatic API. Use to validate prerequisites, record analytics, or cancel printing.
Arguments - (PrintStartEventArgs):
-
fileName- The document file name being printed. -
cancel- Default:false. Set totrueto cancel the print operation.
Setting args.cancel = true prevents the client-side print flow; for server-backed printing it prevents the service request that produces print output. Find the code example here
Minimal usage example:
import { Component, ViewChild, OnInit } from '@angular/core';
import {
PdfViewerComponent,
PdfViewerModule,
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
TextSearchService,
TextSelectionService,
PrintService,
AnnotationService,
FormFieldsService,
FormDesignerService,
PageOrganizerService,
PrintStartEventArgs,
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
standalone: true,
imports: [PdfViewerModule],
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
TextSearchService,
TextSelectionService,
PrintService,
AnnotationService,
FormFieldsService,
FormDesignerService,
PageOrganizerService,
],
template: `
<ejs-pdfviewer
#pdfviewer
id="PdfViewer"
[documentPath]="document"
[resourceUrl]="resource"
(printStart)="printStart($event)"
style="height: 100vh; width: 100%; display: block"
>
</ejs-pdfviewer>
`,
})
export class AppComponent implements OnInit {
@ViewChild('pdfviewer')
public pdfviewerControl!: PdfViewerComponent;
public document: string =
'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string =
'https://cdn.syncfusion.com/ej2/23.2.6/dist/ej2-pdfviewer-lib';
ngOnInit(): void {
// Initialization logic (if needed)
}
printStart(args: PrintStartEventArgs): void {
console.log('Print action has started for file: ' + args.fileName);
}
}printEnd
This event is emitted after the printing completes. Use to finalize analytics, clear temporary state, or notify users.
Arguments - (PrintEndEventArgs):
-
fileName- The printed document name.
Minimal usage example:
import { Component, ViewChild, OnInit } from '@angular/core';
import {
PdfViewerComponent,
PdfViewerModule,
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
TextSearchService,
TextSelectionService,
PrintService,
AnnotationService,
FormFieldsService,
FormDesignerService,
PageOrganizerService,
PrintEndEventArgs,
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
standalone: true,
imports: [PdfViewerModule],
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
TextSearchService,
TextSelectionService,
PrintService,
AnnotationService,
FormFieldsService,
FormDesignerService,
PageOrganizerService,
],
template: `
<ejs-pdfviewer
#pdfviewer
id="PdfViewer"
[documentPath]="document"
[resourceUrl]="resource"
(printEnd)="printEnd($event)"
style="height: 100vh; width: 100%; display: block"
>
</ejs-pdfviewer>
`,
})
export class AppComponent implements OnInit {
@ViewChild('pdfviewer')
public pdfviewerControl!: PdfViewerComponent;
public document: string =
'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string =
'https://cdn.syncfusion.com/ej2/23.2.6/dist/ej2-pdfviewer-lib';
ngOnInit(): void {
// Initialization logic (if needed)
}
printEnd(args: PrintEndEventArgs): void {
console.log('Printed file name: ' + args.fileName);
}
}