How can I help you?
Print events in React PDF Viewer
9 Mar 20263 minutes to read
This page lists each event emitted by the React 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:
<PdfViewerComponent
id="PdfViewer"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
resourceUrl="https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"
printStart={(args: PrintStartEventArgs) => {
console.log('Print action has started for file: ' + args.fileName);
}}
style={{ height: '100%' }}
>
<Inject
services={[
TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification,
Annotation, FormDesigner, FormFields
]}
/>
</PdfViewerComponent>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:
<PdfViewerComponent
id="PdfViewer"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
resourceUrl="https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"
printEnd={(args: PrintEndEventArgs) => {
console.log('Printed file name: ' + args.fileName);
}}
style={{ height: '100%' }}
>
<Inject
services={[
TextSelection, TextSearch, Print, Navigation, Toolbar, Magnification,
Annotation, FormDesigner, FormFields
]}
/>
</PdfViewerComponent>