---
title: "Prevent sharing of PDF files on iOS | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/document-security/prevent-sharing/"
md_url: "https://www.nutrient.io/guides/ios/document-security/prevent-sharing.md"
last_updated: "2026-05-15T17:18:57.893Z"
description: "Learn to prevent document sharing in iOS by excluding specific bar button items from the `PDFViewController` toolbar in Nutrient iOS SDK. Customize user access effectively."
---

# Prevent sharing of PDF files on iOS

Nutrient enables you to customize the [document sharing experience](https://www.nutrient.io/guides/ios/miscellaneous/document-sharing.md). To prevent your end users from sharing documents, you need to exclude the bar button items that allow sharing from your [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller)’s navigation item’s `leftBarButtonItems` or `rightBarButtonItems`.

Here’s the list of bar button items you need to exclude from the main toolbar:

| Property                 | Description                                                                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------ |
| [`openInButtonItem`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/openinbuttonitem)   | Presents the `UIDocumentInteractionController` controller to open a document in other apps.            |
| [`emailButtonItem`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/emailbuttonitem)    | Presents the `MFMailComposeViewController` to send a document via email.                               |
| [`messageButtonItem`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/messagebuttonitem)  | Presents the `MFMessageComposeViewController` to send a document via SMS/iMessage.                     |
| [`activityButtonItem`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/activitybuttonitem) | Presents the `UIActivityViewController` for various actions, including many of the above button items. |

The example below shows how to customize the main toolbar’s button to prevent sharing:

```swift

let pdfController =...

// Make sure `activityButtonItem`, `openInButtonItem`, `emailButtonItem`, and `messageButtonItem` are excluded from the `leftButtonItems` and `rightButtonItems` arrays.
let leftButtonItems = [controller.settingsButtonItem, controller.outlineButtonItem]
let rightButtonItems = [controller.searchButtonItem, controller.annotationButtonItem]

pdfController.navigationItem.setLeftBarButtonItems(leftButtonItems, for:.document, animated: false)
pdfController.navigationItem.setRightBarButtonItems(rightButtonItems, for:.document, animated: false)

```

For more details, see both our guide about [customizing the main toolbar](https://www.nutrient.io/guides/ios/user-interface/main-toolbar.md) and the sharing examples from [Nutrient Catalog](https://www.nutrient.io/guides/ios/getting-started/example-projects.md#nutrient-catalog).
---

## Related pages

- [Securing PDFs by adding watermarks on iOS](/guides/ios/document-security/add-a-watermark.md)
- [Introduction to PDF encryption on iOS](/guides/ios/security/introduction-to-encryption.md)
- [Decrypt PDFs with AES on iOS](/guides/ios/security/aesdataprovider.md)
- [Document security on iOS](/guides/ios/document-security.md)
- [Encrypt PDFs with AES on iOS](/guides/ios/security/encrypt-or-decrypt-files-on-the-server.md)
- [Creating password-protected PDFs on iOS](/guides/ios/document-security/add-a-password.md)
- [Managing PDF restrictions on iOS](/guides/ios/document-security/set-permissions.md)

