> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/get-started/integrations/sharepoint/get-started.md).

# Integrate Apryse WebViewer into Sharepoint

Integrate Apryse WebViewer with Sharepoint for pdf viewing, annotating, editing, and creating PDFs.

In this guide, you'll integrate Apryse WebViewer into SharePoint Online as a web part. You'll do this by cloning the SharePoint sample repository, then integrating WebViewer with the clone.

<a href="https://github.com/ApryseSDK/sharepoint-integration-examples/" class="button primary">Get the SharePoint sample source code here</a>

## Prerequisites

You'll need to do the following before you start:

* Install [**Node** ](https://nodejs.org/en/blog/release/v22.21.0)[v22.21.0](https://nodejs.org/en/blog/release/v22.21.0)[ **and NPM**](https://nodejs.org/en/blog/release/v22.21.0).
* Install SPFx: [v1.21.1](https://learn.microsoft.com/en-us/sharepoint/dev/spfx/release-1.21).
* [Install WebViewer](/web/get-started/readme.md).

{% @apryse-download-button/apryse-download-button id="WebViewer\_web\_web" title="Download WebViewer" showVersion="true" %}

* Install [**Node Version Manager**](http://npm.github.io/installation-setup-docs/installing/using-a-node-version-manager.html) (optional, but recommended).
* Get your Apryse trial key.

{% @apryse-license-key/apryse-license-key platform="WEB\_VIEWER" variant="full" %}

* Set up your Sharepoint dev environment. You'll also need to be familiar with using the Sharepoint dev environment. If you're not familiar with using the environment, create some sample projects using the environment first.
  * For step-by-step help on setting up a SharePoint development environment, see the following:
    * [SharePoint DX Setup Guide](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview/)
    * [Set up your Microsoft 365 Tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant/)
    * [Set up your SharePoint Framework Development Environment](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment/)

{% hint style="info" %}
**License Key Required**

The trial of Apryse SDK requires a trial license key, which is provided in the box titled "License Key". A commercial license key is required for use in a production environment. Please [contact sales](https://apryse.com/form/contact-sales) to purchase a commercial key or if you need any other license key assistance.
{% endhint %}

{% hint style="warning" %}
**Keep your license keys confidential.**

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).
{% endhint %}

## Sharepoint web part setup, development, and deployment

### 1. Initial Setup

1. Ensure you're running Node.js version `v22.21.0`. You can check by running the following in the console:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```shell
node -v
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. Enable the custom scripts by following the [Microsoft Guide and configuration](https://docs.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script#to-allow-custom-script-on-other-sharepoint-sites) guide. It may take up to 24hrs for the configuration to to complete.

{% hint style="info" %}
By default, the custom scripts option is disabled.
{% endhint %}

{% tabs %}
{% tab title="Windows" %}
If you are on a Windows machine, you can achieve this using the [SharePoint Online Management Shell](https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps) and the following commands:

{% code lineNumbers="true" %}

```sh
Connect-SPOService -Url <AdminSiteURL> -Credential <AdminUser>
Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0
```

{% endcode %}

{% hint style="info" %}
The following are placeholder variables for the SharePoint Environment:

* The `<AdminSiteURL>` is the admin SharePoint URL, typically in the form of `[your-tenant-name]-admin.sharepoint.com`.
* The `<SiteURL>` is the target SharePoint Site you are modifying, usually in the form of `[your-tenant-name].sharepoint.com/sites/[sitename]`.
* The `<your-tenant-id>` is your tenant ID. For example, `contoso.sharepoint.com`.
* The `<your-sharepoint-site-name>` is the SharePoint Site Name where WebViewer was added. For example, "All Company" is a default Site Name added to a fresh SharePoint environment.
* The `<your-shared-document-url>` points to the SharePoint Site where WebViewer was uploaded. For example, `<your-tenant-id>.sharepoint.com/sites/<sitename>/Shared Documents`.
  {% endhint %}
  {% endtab %}

{% tab title="macOS" %}
If you are on a MacOS machine, you can achieve this with the [PnP Powershell](https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets/) by using the following commands:

{% code lineNumbers="true" %}

```sh
Set-PnPSite -Identity https://{your-tenant-id}.sharepoint.com/sites/${site-name} -NoScriptSite $false
```

{% endcode %}
{% endtab %}
{% endtabs %}

3. In the Document Library of your SharePoint site, create a **Webviewer** folder.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-131242217998167ca701d8abad3c5435d055a118%2Fd04276a1fa38eac6f49592e57b6f0a44bbe69e8f-2930x1308.png?alt=media)

4. Create a child folder, **js**, inside the **Webviewer** folder.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-8d7d5f80be375b8bcb50088ca2af3d35fc20b2a7%2F3c40decae319355425231b825f16dad6e82a75e5-2930x1306.png?alt=media)

5. Upload the **lib** folder extracted from the `WebViewer.zip` to the **js** folder.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-70235aa17ef33afcb22e639ea74f39f2b74f7c96%2Fdf5c03739076e7e25e82db2a6efa0ac8764c5a28-2930x1342.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-ef0b4bf7658d3e3ee58b9b9ea7be566efa23b869%2Fd8d76eab849d361cbc515d83039c63afa355dc0e-2912x1302.png?alt=media)

The webviewer lib folder is now available from the url `https://.sharepoint.com/sites//Shared Documents/Webviewer/js/lib`.

### Development

1. Clone the [`sharepoint-integration-examples`](https://github.com/ApryseSDK/sharepoint-integration-examples/) sample from github:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
git clone https://github.com/ApryseSDK/sharepoint-integration-examples.git
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. Enter the **sharepoint-web-part** folder and use `npm` to install `gulp`, `yeoman` and `Microsoft SharePoint Generator`:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
cd sharepoint-web-part
npm i -g gulp-cli yo @microsoft/generator-sharepoint
```

{% endcode %}
{% endtab %}
{% endtabs %}

3. Install all the packages through the following command:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```shell
npm install
```

{% endcode %}
{% endtab %}
{% endtabs %}

4. Create a `.env` file in the **sharepoint-web-part** folder and include the following parameters in the `.env` file:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
TENANT_ID=<your-tenant-id>
SITE_NAME=<your-sharepoint-site-name>
WEBVIEWER_LIB_FOLDER_PATH=Webviewer/js/lib
FOLDER_URL=<your-shared-documents-url> // This is where you save the opened local files in the webviewer
```

{% endcode %}
{% endtab %}
{% endtabs %}

5. Change the `initialPage` property in `sharepoint-web-part/config/serve.json` by replacing it with your tenant id and SharePoint site name.

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
{
...,
// replace with your tenant id and SharePoint site name
"initialPage": "https://<your-tenant-id>.sharepoint.com/sites/<site-name>/_layouts/workbench.aspx" 
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

6. Run the following to start the web part in the workbench:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
gulp serve
```

{% endcode %}
{% endtab %}
{% endtabs %}

7. If this is your first time setting up the SharePoint Framework, you must call the following:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
gulp trust-dev-cert
```

{% endcode %}
{% endtab %}
{% endtabs %}

After your local SharePoint instance is running, you should see a blank SharePoint canvas like in the screenshot below. You can add an Apryse WebViewer web part by adding a new web part to the page and selecting the **webviewer** web part.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-fd1a587e6f1f388179eb1d778fc6f146823c8e56%2F7fdf0bf301e476d89646cbbc7fc02dfe3c324cd4-2932x1554.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-d0003b2a94b85d8fa90181c10f7edf89ca382b40%2F9f255cec170eea8e9441885a1edda801503460d5-3024x1562.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-8b0c118b2ac0d326e112ced1cdb16175ba5b647b%2Faf653c3cbe6665be08ac3047aa451f7d5555caeb-3024x1562.png?alt=media)

You can now open a local file in the Webviewer.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-7702c2caabed8c21ba72a40af0656c21b8e3e29c%2Ffc2792b610e83d7746a39cbf91e01964cf2fd011-3024x1564.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-53a50d925ddd8d6b47f784a5735fe62d15b4cf6c%2Fdbf6f61fd23c11fc72606c48c7dbfe9f09f291a0-3024x1564.png?alt=media)

### Deployment

1. Run the folllowing to generate the `webviewer.sppkg` file in the **sharepoint-web-part/sharepoint** folder:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
gulp bundle --ship
gulp package-solution --ship
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. Navigate to the SharePoint admin center, then go to the **More features** page. It should be `https://<your-tenant-id>-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/classicFeatures`.
3. Click the **Open** button under the **App** section.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-871df8e911195b6fcce75b5146e55ca9cdc60024%2F1978f608db81346ba5401ff49e13f7f2d04788f5-3584x1718.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-87405d15e1a7f1935b87e703edcbd76cc14e36c0%2Fa8f10d4151a011353b6da479343b7596d2f1777e-1920x875.png?alt=media)

4. Click the **Upload** button to upload the `webviewer.sppkg` file, then select the `webviewer.sppkg` file.

{% hint style="info" %}
The `.sppkg` file is located under the sharepoint/solution folder.
{% endhint %}

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-3f7d44e7bf22544079b38652ac5780b0438118a5%2Ff6d8e7217741f625e3671ee90a6cbd9ee63881c9-1920x976.png?alt=media)

5. After uploading, enable the app by selecting **Only enable this app**.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-46c290358ed91f12d4d7d54fc4d016d3de09d3be%2F27f4f0d3a6c09423af2b0e6be9e210faf2b76ba6-1920x920.png?alt=media)

6. Click the **Settings** button on the top right in the SharePoint site, then click **Add an app**.
7. Enable the `webviewer-client-side-solution` in **My Apps**.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-acecf6a09e419787da81983014dba521d67da50c%2F5a890ed050a7c7e23ab43e1b3d1d86c1b18dcb9e-1920x929.png?alt=media)

8. Click **+ New** button, then select **Site Page** to create a new site page in the SharePoint site.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-df2bd190acc739941553213cc4741449574d8585%2F4609237a897a8879eb0a64b0d2f2896e85668a47-1920x975.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-f6ab22e385e6dd4bc3941370856d116c7139b86a%2F628605394b383f94e442a7deb341bbfcbf7c2ea7-1920x844.png?alt=media)

9. Rename the page to **Webviewer**, then add a one column section.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-36f0a8017fb783a6f0580e4c272aa31ed476995c%2F01f7fdd16053da07f39176388d0af0d4120c2045-1920x844.png?alt=media)

10. Click the **+** button in the new section, select the **webviewer** web part, then publish the page.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-d2b4a4dd877ee4fd20713a092849498923d00fb6%2Fe1044b41b4c00e743027b1f5a44a06fdb029a39a-1920x893.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-79b76457f175b826d191e6fab94c82992dddae33%2F2060b37e778aa32176b956cfb5d4280a5bea1415-1872x891.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-992f5c5da3bedad10c757fd04aab99da07b2c9cc%2Fe6cb82416a7959199541074db87df5b82147252e-1865x844.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-344e759a78a7ba6ebca396f2cc25cf1eddaedea7%2F7c4fb8ac3f2fbb922619e0dbd6caa59f88f59895-1865x844.png?alt=media)

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-95d9753eedc9bf24801958c54f975f62b45445c1%2F4fd072c75ff5a96842ca934584351f9c8d6fcdab-2932x1262.png?alt=media)

## Integrate with SharePoint extension

To open files in SharePoint Documents Library, you must integrate with SharePoint extension. This extension allows you to add a button to any List View in SharePoint, such as your document libraries. You'll be adding a **Open in Apryse** Button as a menu option to open and process any documents in Webviewer.

### Get started

1. Create a `.env` file within the **sharepoint-extension** folder in the **sharepoint-integration-examples** repository. Add the following parameters in the `.env` file:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
SITE_PAGE=Webviewer.aspx
SHAREPOINT_SITE_URL=https://<your-tenant-id>.sharepoint.com/sites/<site-name>
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. In the **sharepoint-extension** in the terminal, Run the following:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
npm install
```

{% endcode %}
{% endtab %}
{% endtabs %}

3. Change the `pageUrl` in the `serve.json` in the **sharepoint-extension/config** folder by replacing the tenant id and site name:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
{
    ...,
    pageUrl: "https://<your-tenant-id>.sharepoint.com/sites/<site-name>/Shared%20Documents/Forms/AllItems.aspx"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

4. Run the following command:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
gulp serve
```

{% endcode %}
{% endtab %}
{% endtabs %}

This will generate a new window in the Document Library, and, a popup and warning for you to allow debug scripts.

5. Select the `Load debug scripts` option in the popup.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-1f20ff82479291efa555ba08d9a9e9684507ba21%2F67dca69048432d071397723c3f18c1cdbafb902e-962x365.png?alt=media)

6. You should be able to see the `Open in Apryse` button after right click on a document in the Document Library.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-70920e1779f0d85e866b5bac6771a6120192f376%2F69a6ac07a4731cb80714ce74901cdafc06165982-1278x731.png?alt=media)

7. Click the `Open in Apryse` button and it will direct you to the page, by default, that you specified in the `.env` file. In this case, it should be the `https://<your-tenant-id>.sharepoint.com/sites/<site-name>/SitePages/<site-page>.aspx` page that has the webviewer web part.

{% hint style="info" %}
SharePoint Framework currently has issues hosting workbench on any portother than 4321. This means it's hard to configure to have the Web Part and the extension running locally at the same time. We recommend deploying either the Web Part or the extension, and host the other one locally.
{% endhint %}

### Deploy the extension

1. Use the following commands, similar to deploying the SharePoint Web Part, to generate the `sharepoint-extension.sppkg` file in the **sharepoint-extension/sharepoint/solution** folder:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
gulp bundle --ship
gulp package-solution --ship
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. Upload the `sharepoint-extension.sppkg` file to the **Apps** in **SharePoint Admin center** and enable it for the website.

{% hint style="info" %}
You should see the **Open in Apryse** button after you right-click on a document in the Document Library.
{% endhint %}

## Next step

<a href="/web/what-is-webviewer/usage.md" class="button primary">Usage</a><a href="/web/get-started/guides.md" class="button primary">Guides</a><a href="/web/get-started/samples.md" class="button primary">Samples</a><a href="https://sdk.apryse.com/api/web/index.html" class="button primary">API docs</a>

{% hint style="info" %}
For more information on how to call WebViewer API, check out this blog.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/get-started/integrations/sharepoint/get-started.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
