diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index 784ce2d11..3a0bfd658 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -1002,7 +1002,7 @@
  • Annotations in Mobile view
  • -
  • Redaction +
  • Redaction and Security
  • Interaction Mode
  • diff --git a/Document-Processing/PDF/PDF-Viewer/react/Redaction/prevent-copy-and-print.md b/Document-Processing/PDF/PDF-Viewer/react/Redaction/prevent-copy-and-print.md new file mode 100644 index 000000000..86301b847 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/Redaction/prevent-copy-and-print.md @@ -0,0 +1,108 @@ +--- +layout: post +title: Prevent Copy or Print in React PDF Viewer | Syncfusion +description: Learn how to prevent printing and copying in the React PDF Viewer using viewer settings or server-side permission flags. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Prevent Copy or Print in React PDF Viewer + +## Overview +This guide shows how to prevent users from copying text or printing documents in EJ2 React PDF Viewer. + +**Outcome:** You will learn server-side and client-side options to restrict copy/print with a complete React example. + +## Steps + +1. Use a PDF with permissions already set + - Load a PDF that already disallows copy or print functionality itself. The Viewer enforces these permission automatically. + +2. Pre process restrictions in server-side + - Use Syncfusion PDF Library to set permission flags before sending the file to the client. See the server-side example below. + - Disabling print and copy in server-side automatically enforces them in the PDF Viewer. + +3. Hide/disable UI elements in the viewer + - Print, download and copy options can be disabled or hidden in the viewer regardless of the PDF's permissions. + - Print and download options can be hidden in the viewer's primary toolbar. See [primary toolbar customization](../toolbar-customization/primary-toolbar). + - Copy option in the context menu can be disabled in the PDF Viewer. See [customize context menu](../context-menu/custom-context-menu). + +4. Disable print programmatically in the viewer + - Set [`enablePrint`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enableprint) to `false` to disable the print UI even if the PDF allows printing. + +5. Disable copy via text-selection UI + - Set [`enableTextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enabletextselection) to `false` to stop text selection and copying through the viewer UI. + +**Example:** + +The following is a complete React example that demonstrates disabling printing and text selection in the viewer. + +{% tabs %} +{% highlight ts tabtitle="App.tsx" %} +{% raw %} +import { PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject } from '@syncfusion/ej2-react-pdfviewer'; +export default function App() { + return ( +
    + + + +
    + ); +} +{% endraw %} +{% endhighlight %} +{% endtabs %} + +**Expected result**: +- The viewer renders the PDF. +- Print button and print-related UI are hidden/disabled. +- Text selection and copy operations from the viewer are disabled. + +## Server-side: Enforce restrictions with Syncfusion PDF Library + +Process the PDF on the server to set permissions that disallow printing or copying. The viewer will respect these permissions when the PDF is loaded. + +{% tabs %} +{% highlight csharp tabtitle="Program.cs" %} +{% raw %} +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Security; + +using FileStream inputStream = new FileStream( + Path.GetFullPath("input.pdf"), + FileMode.Open, + FileAccess.Read +); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream); +loadedDocument.Security.Permissions = PdfPermissionsFlags.EditContent | PdfPermissionsFlags.EditAnnotations | PdfPermissionsFlags.FillFields | PdfPermissionsFlags.AssembleDocument | PdfPermissionsFlags.AccessibilityCopyContent; +loadedDocument.Save(Path.GetFullPath(@"output.pdf")); +loadedDocument.Close(true); +{% endraw %} +{% endhighlight %} +{% endtabs %} + +Set the [`PdfPermissionsFlags`](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Security.PdfPermissionsFlags.html) appropriately to remove copy/print rights. The example above shows how to set flags. + +## Troubleshooting + +- If the Print button still appears: + - Confirm [`enablePrint`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enableprint) is set to `false` on `PdfViewerComponent`. + - If the PDF explicitly allows printing, prefer server-side removal of print permission. +- If text can still be copied: + - Confirm [`enableTextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enabletextselection) is set to `false` and your app isn't adding secondary copy handlers. + +## Related topics + +- [Redact Sensitive content in PDF](../Redaction/overview) +- [Redaction APIs](../Redaction/programmatic-support) +- [Redaction toolbar](../Redaction/toolbar) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/Redaction/secure-pdf-viewing.md b/Document-Processing/PDF/PDF-Viewer/react/Redaction/secure-pdf-viewing.md new file mode 100644 index 000000000..ddeb4f7ce --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/Redaction/secure-pdf-viewing.md @@ -0,0 +1,51 @@ +--- +layout: post +title: Secure PDF Viewing in React Apps using PDF Viewer | Syncfusion +description: Best practices for securing PDF content in React apps using the EJ2 React PDF Viewer and server-side processing. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Secure PDF Viewing in React Apps + +## Overview + +This page explains best practices for securing PDF content displayed in React applications using the EJ2 React PDF Viewer and server-side processing. It covers encryption, permission restrictions, redaction, preprocessing, and secure API usage. + +## Why Secure Viewing matters + +- Protects user privacy and compliance-sensitive data. +- Reduces risk from hidden/metadata content and unauthorized copying or printing. +- Limits liability when distributing PDFs to untrusted clients. + +## Common security guidelines + +This section outlines common security controls and how they interact with the viewer. + +- **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) + +- **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) + +- **Redaction**: Permanently remove text, images, or regions at the document level on the server before delivering the file. Redaction produces a new PDF with the sensitive content removed. See [redacting sensitive content](./overview) + +- **Preprocessing**: On the server, remove metadata, embedded files, hidden layers, form field values, JavaScript actions, and flatten form fields. Compress and linearize PDFs if needed. See [preprocessing PDFs](../document-handling/preprocess-pdf) + +## Design decisions and trade-offs + +- Client vs server enforcement: Client-side settings which disable disabling print in the viewer improve user experience but are not a security boundary. True protection requires server-side changes which actually enforces the restrictions (encryption, permissions, redaction). + +- Usability vs security: Strong encryption and sanitizing heavily can break some workflows (search, form interactivity). Choose operations appropriate to the document life cycle. + +- Redaction permanence: Redaction is irreversible; keep originals securely archived if needed for audit. + +## Best practices + +- Encrypt PDFs with strong passwords when they must remain unreadable without credentials. +- Apply permission flags for copying/printing via server-side PDF library; treat viewer-side options as UX controls only. +- Perform redaction on the server to permanently remove sensitive content. +- Strip metadata, embedded files, comments, and JavaScript before serving. +- Flatten form fields and sanitize form data when exporting public PDFs. +- Use short-lived, authenticated URLs or a tokenized download endpoint rather than serving files from a public bucket. +- Log access and apply rate limits and CORS policies on APIs that serve PDFs. \ No newline at end of file