Skip to content

Commit 910cdb8

Browse files
1012499: Addressed review changes
1 parent e93995a commit 910cdb8

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

Document-Processing-toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@
10271027
<li><a href="/document-processing/pdf/pdf-viewer/react/security/overview">Overview</a></li>
10281028
<li><a href="/document-processing/pdf/pdf-viewer/react/security/prevent-copy-and-print">Prevent copy/print</a></li>
10291029
<li><a href="/document-processing/pdf/pdf-viewer/react/security/secure-pdf-viewing">Secure PDF viewing in react apps</a></li>
1030-
<li><a href="/document-processing/pdf/pdf-viewer/react/security/restricting-download">Restrict download</a></li>
1030+
<li><a href="/document-processing/pdf/pdf-viewer/react/security/restricting-download-and-print">Restrict download/print</a></li>
10311031
</ul>
10321032
</li>
10331033
<li><a href="/document-processing/pdf/pdf-viewer/react/interaction-mode">Interaction Mode</a></li>

Document-Processing/PDF/PDF-Viewer/react/security/restricting-download.md renamed to Document-Processing/PDF/PDF-Viewer/react/security/restricting-download-and-print.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
---
22
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.
55
platform: document-processing
66
control: PDF Viewer
77
documentation: ug
88
domainurl: ##DomainURL##
99
---
1010

11-
# Restrict download in React PDF Viewer
11+
# Restrict download or print in React PDF Viewer
1212

1313
## Overview
1414

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.
1616

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.
1818

1919
## Prerequisites
2020
- EJ2 React PDF Viewer installed and basic viewer setup completed. See [getting started guide](../getting-started)
2121

2222
## Steps
2323

24-
### 1. Hide the Download button in the primary toolbar
24+
### 1. Hide the Download and print button in the primary toolbar
2525

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.
2727

2828
### 2. Block download with the `downloadStart` event
2929

3030
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).
3131

32-
**Example**:
32+
### 3. Block download with the `printStart` event
3333

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.
3539

3640
{% tabs %}
3741
{% highlight ts tabtitle="App.tsx" %}
@@ -48,6 +52,11 @@ export default function App() {
4852
args.cancel = true;
4953
console.log('Download restricted.');
5054
};
55+
const onPrintStart = (args: any) => {
56+
// Cancels every print attempt
57+
args.cancel = true;
58+
console.log('Print restricted.');
59+
};
5160

5261
return (
5362
<div style={{ height: '640px' }}>
@@ -56,6 +65,7 @@ export default function App() {
5665
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
5766
resourceUrl="https://cdn.syncfusion.com/ej2/32.2.5/dist/ej2-pdfviewer-lib"
5867
downloadStart={onDownloadStart}
68+
printStart={onPrintStart}
5969
>
6070
<Inject services={[Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView,
6171
BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, Print]} />
@@ -73,11 +83,14 @@ export default function App() {
7383

7484
## Troubleshooting
7585

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.
7787

7888
- If downloads still occur despite the handler, confirm `downloadStart={onDownloadStart}` is present on `PdfViewerComponent` and that the handler sets `args.cancel = true`.
7989

90+
- If print still occurs despite the handler, confirm `printStart={onPrintStart}` is present on `PdfViewerComponent` and that the handler sets `args.cancel = true`.
91+
8092
## Related topics
8193

8294
- [Customize primary toolbar](../toolbar-customization/primary-toolbar)
8395
- [`downloadStart` event reference](../events#downloadstart)
96+
- [`printStart` event reference](../events#printstart)

Document-Processing/PDF/PDF-Viewer/react/security/secure-pdf-viewing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This page explains best practices for securing PDF content displayed in React ap
2424

2525
This section outlines common security controls and how they interact with the viewer.
2626

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).
2828

2929
- **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)
3030

@@ -52,4 +52,5 @@ This section outlines common security controls and how they interact with the vi
5252

5353
## See also
5454

55-
- [Prevent copy/print](./prevent-copy-and-print)
55+
- [Prevent copy/print](./prevent-copy-and-print)
56+
- [Restrict download/print](./restricting-download-and-print)

0 commit comments

Comments
 (0)