You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Viewer/react/security/restricting-download-and-print.md
+23-10Lines changed: 23 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,37 +1,41 @@
1
1
---
2
2
layout: post
3
-
title: Restrict download in React PDF Viewer | Syncfusion
4
-
description: Learn how to prevent end users from downloading PDFs displayed by the EJ2 React PDF Viewer using toolbar and events.
3
+
title: Restrict download or print in React PDF Viewer | Syncfusion
4
+
description: Learn how to prevent end users from downloading or printing PDFs displayed by the EJ2 React PDF Viewer using toolbar and events.
5
5
platform: document-processing
6
6
control: PDF Viewer
7
7
documentation: ug
8
8
domainurl: ##DomainURL##
9
9
---
10
10
11
-
# Restrict download in React PDF Viewer
11
+
# Restrict download or print in React PDF Viewer
12
12
13
13
## Overview
14
14
15
-
This guide shows how to prevent end users from downloading PDFs displayed by the EJ2 React PDF Viewer.
15
+
This guide shows how to prevent end users from downloading and printing PDFs displayed by the EJ2 React PDF Viewer.
16
16
17
-
**Outcome:** The Download button is removed from the primary toolbar and any download attempt is blocked by the `downloadStart`event handler.
17
+
**Outcome:** The Download and print button are removed from the primary toolbar and any download or print attempt is blocked by the [`downloadStart`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#downloadstart) and [`printStart`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#printstart)event handlers.
18
18
19
19
## Prerequisites
20
20
- EJ2 React PDF Viewer installed and basic viewer setup completed. See [getting started guide](../getting-started)
21
21
22
22
## Steps
23
23
24
-
### 1. Hide the Download button in the primary toolbar
24
+
### 1. Hide the Download and print button in the primary toolbar
25
25
26
-
The viewer toolbar items are controlled by `toolbarSettings.toolbarItems`. Omit `DownloadOption` from that array to remove the Download button from the primary toolbar. See [primary toolbar customization](../toolbar-customization/primary-toolbar) for code examples.
26
+
The viewer toolbar items are controlled by [`toolbarSettings.toolbarItems`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/toolbarsettings#toolbaritems). Omit `DownloadOption`and `PrintOption`from that array to remove the Download and print button from the primary toolbar. See [primary toolbar customization](../toolbar-customization/primary-toolbar) for code examples.
27
27
28
28
### 2. Block download with the `downloadStart` event
29
29
30
30
The viewer raises the [`downloadStart`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#downloadstart) event whenever a download is initiated. Add an event handler and set `args.cancel = true` to block the operation regardless of how it was triggered (toolbar, API, or custom UI).
31
31
32
-
**Example**:
32
+
### 3. Block download with the `printStart` event
33
33
34
-
The following is a complete, runnable React example that cancels every download attempt in `onDownloadStart()`.
34
+
The viewer triggers the [`printStart`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#printstart) event whenever a print action is initiated. Attach an event handler to the event and set `args.cancel = true` to block the operation regardless of how it was triggered.
35
+
36
+
**Complete Example**:
37
+
38
+
The following is a complete, runnable React example that cancels every download or print attempt.
35
39
36
40
{% tabs %}
37
41
{% highlight ts tabtitle="App.tsx" %}
@@ -48,6 +52,11 @@ export default function App() {
@@ -73,11 +83,14 @@ export default function App() {
73
83
74
84
## Troubleshooting
75
85
76
-
- If the Download button is still visible, remove `DownloadOption` from `toolbarSettings.toolbarItems`, and ensure no custom toolbar rendering inserts the Download control.
86
+
- If the Download or print button is still visible, remove `DownloadOption`and `PrintOption`from [`toolbarSettings.toolbarItems`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/toolbarsettings#toolbaritems), and ensure no custom toolbar rendering inserts the Download control.
77
87
78
88
- If downloads still occur despite the handler, confirm `downloadStart={onDownloadStart}` is present on `PdfViewerComponent` and that the handler sets `args.cancel = true`.
79
89
90
+
- If print still occurs despite the handler, confirm `printStart={onPrintStart}` is present on `PdfViewerComponent` and that the handler sets `args.cancel = true`.
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Viewer/react/security/secure-pdf-viewing.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ This page explains best practices for securing PDF content displayed in React ap
24
24
25
25
This section outlines common security controls and how they interact with the viewer.
26
26
27
-
-**Password protection**: Use user/owner passwords on PDFs. The viewer can open password-protected files when the password is provided at load time. Password-based encryption prevents opening without credentials. See [loading password protected PDFs](../document-handling/load-password-pdf)
27
+
-**Password protection**: Use user/owner passwords on PDFs. The viewer can open password-protected files when the password is provided at load time. Password-based encryption prevents opening without credentials. See [loading password protected PDFs](../document-handling/load-password-pdf) and [encrypting PDF documents](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/working-with-security).
28
28
29
29
-**Permission restrictions**: Set PDF permissions (copy, print) using Syncfusion PDF library. The viewer respects these permissions at display time but cannot enforce protections if the client receives an unprotected full file. See [prevent copy and print permissions](./prevent-copy-and-print)
30
30
@@ -52,4 +52,5 @@ This section outlines common security controls and how they interact with the vi
0 commit comments