Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ open-iconic
.next/
.nuxt/
dist/
analytics.js
analytics.js
.DS_Store
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"./examples/blazor/wasm/wwwroot/css/*",
"./examples/wasm-benchmark/*",
"./examples/asp-net/*",
"./examples/svelte-kit"
"./examples/svelte-kit",
"./examples/salesforce/*"
],
"ignoreUnknown": true
},
Expand Down
52 changes: 29 additions & 23 deletions examples/salesforce/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# PSPDFKit for Salesforce Integration
> ⚠️ **Repository Moved**
> This repository has been moved to https://github.com/PSPDFKit/nutrient-web-examples/tree/main/examples/salesforce.
> Please update your bookmarks and issues accordingly.
>
> This repo is now archived and will no longer receive updates.

# Nutrient Salesforce SDK Integration

## Integrate into a New Salesforce Project as a Lightning Web Component

PSPDFKit for Salesforce enables you to open PDF, JPG, PNG, and TIFF files inside Salesforce. This unlocks the full functionality of PSPDFKit in Salesforce, including PDF generation, redaction, and signatures.
Nutrient Salesforce SDK enables you to open PDF, JPG, PNG, and TIFF files inside Salesforce. This unlocks the full functionality of Nutrient Web SDK in Salesforce, including PDF generation, redaction, and signatures.

This README explains how to integrate PSPDFKit into a new Salesforce project. The integration works as a [Lightning web component (LWC)][lwc] that you can add to any Salesforce organization.
This README explains how to integrate Nutrient Web SDK into a new Salesforce project. The integration works as a [Lightning web component (LWC)][lwc] that you can add to any Salesforce organization.

For more information on integrating PSPDFKit into an existing Salesforce project, see the [PSPDFKit for Salesforce documentation][salesforce docs].
For more information on integrating Nutrient Web SDK into an existing Salesforce project, see the [Nutrient Salesforce SDK documentation][salesforce docs].

PSPDFKit for Salesforce shares the same APIs as Nutrient Web SDK Standalone. For more information on customizing your Salesforce application, see the [Nutrient Web SDK Standalone documentation][web docs].
Nutrient Salesforce SDK shares the same APIs as Nutrient Web SDK Standalone. For more information on customizing your Salesforce application, see the [Nutrient Web SDK Standalone documentation][web docs].

## Requirements

Expand All @@ -21,17 +27,17 @@ Before continuing, perform all of the following actions:

## Deploying the Package

To deploy the PSPDFKit package to your Salesforce organization, follow these steps.
To deploy the Nutrient Web SDK package to your Salesforce organization, follow these steps.

1. Download the [PSPDFKit for Salesforce project][zip] from GitHub, and then unpack the ZIP file.
1. Download the [Nutrient Salesforce SDK project][zip] from GitHub, and then unpack the ZIP file.

Alternatively, run the following terminal command to clone the [PSPDFKit for Salesforce repository][repo] from GitHub:
Alternatively, run the following terminal command to clone the [Nutrient Salesforce SDK repository][repo] from GitHub:

```bash
git clone https://github.com/PSPDFKit/salesforce.git
```

2. In the terminal, go to the PSPDFKit for Salesforce project folder and run the following command to install the PSPDFKit npm module.
2. In the terminal, go to the Nutrient Salesforce SDK project folder and run the following command to install the Nutrient Web SDK npm module.

Use the following code for npm:

Expand All @@ -45,15 +51,15 @@ To deploy the PSPDFKit package to your Salesforce organization, follow these ste
yarn install
```

3. The PSPDFKit for Salesforce integration example now makes use of the PSPDFKit version available from our CDN at https://cdn.cloud.pspdfkit.com/pspdfkit-web, which means it's no longer limited by Salesforce's upload assets size 5MB limit.
3. The Nutrient Salesforce SDK integration example now makes use of the Nutrient Web SDK version available from our CDN at https://cdn.cloud.pspdfkit.com/pspdfkit-web, which means it's no longer limited by Salesforce's upload assets size 5MB limit.

In order to set the PSPDFKit version you want to use, open `./force-app/main/default/pages/PSPDFKit_InitPSPDFKit.page` and edit the line 7 to reflect the PSPDFKit version. For example, in order to use version 2024.4.0, you should change the URL pointing to the CDN to:
In order to set the Nutrient Web SDK version you want to use, open `./force-app/main/default/pages/Nutrient_InitNutrient.page` and edit the line 7 to reflect the Nutrient Web SDK version. For example, in order to use version 1.0.0, you should change the URL pointing to the CDN to:

```html
<script src="https://cdn.cloud.pspdfkit.com/pspdfkit-web@2024.4.0/pspdfkit.js" type="text/javascript"></script>
<script src="https://cdn.cloud.pspdfkit.com/pspdfkit-web@1.0.0/nutrient-viewer.js" type="text/javascript"></script>
```

You can find the latest version of Nutrient Web SDK in the [PSPDFKit changelog](https://www.nutrient.io/changelog/web/).
You can find the latest version of Nutrient Web SDK in the [Nutrient Web SDK changelog](https://www.nutrient.io/changelog/web/).

4. Run the following command in the terminal to start the Salesforce authentication process:

Expand All @@ -63,47 +69,47 @@ In order to set the PSPDFKit version you want to use, open `./force-app/main/def

5. In the browser window that opens, log in to your Salesforce organization and authorize the Salesforce CLI.

6. In the terminal, run the following command from the PSPDFKit for Salesforce project’s root folder:
6. In the terminal, run the following command from the Nutrient Salesforce SDK project’s root folder:

```bash
sfdx force:source:deploy -x manifest/package.xml
```

## Enabling Users to Use PSPDFKit
## Enabling Users to Use Nutrient Web SDK

To enable users of your Salesforce organization to use PSPDFKit, follow these steps.
To enable users of your Salesforce organization to use Nutrient Web SDK, follow these steps.

1. In Salesforce, go to **Users** > **Permission Sets**.

2. Find **PSPDFKit Admin Access** in the list and click it.
2. Find **Nutrient Admin Access** in the list and click it.

3. Click **Manage Assignments**.

4. Click **Add Assignment**.

5. Select the users you want to authorize to use PSPDFKit.
5. Select the users you want to authorize to use Nutrient.

6. Click **Next**, and then click **Assign**.

## Changing the Security Settings

PSPDFKit for Salesforce requires Lightning Locker to protect Lightning web components, but Salesforce uses Lightning Web Security by default. To change the default security settings, follow these steps.
Nutrient Salesforce SDK requires Lightning Locker to protect Lightning web components, but Salesforce uses Lightning Web Security by default. To change the default security settings, follow these steps.

1. In Salesforce, go to **Security** > **Session Settings**.

2. Deselect **Use Lightning Web Security for Lightning web components**.

3. Scroll down and click **Save**.

## Using the PSPDFKit for Salesforce Integration
## Using the Nutrient Salesforce SDK Integration

To use PSPDFKit in your Salesforce organization, follow these steps.
To use Nutrient Web SDK in your Salesforce organization, follow these steps.

1. Ensure you’re logged in as a user authorized to use PSPDFKit.
1. Ensure you’re logged in as a user authorized to use Nutrient Web SDK.

2. In the top-right corner, open the App Launcher.

3. Search for and select **PSPDFKit**.
3. Search for and select **Nutrient**.

4. Click **browse** to upload local PDF files, or open a file from Salesforce.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global with sharing class PSPDFKitController {
global with sharing class NutrientController {
public static contentVersion contVersion{get;set;}
public static String conbase{get;set;}

Expand Down Expand Up @@ -47,4 +47,4 @@ global with sharing class PSPDFKitController {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@IsTest
public class PSPDFKitControllerTest {
public class NutrientControllerTest {

@testSetup static void setup() {
Account testAccts = new Account(Name = 'TestAcct');
Expand Down Expand Up @@ -27,7 +27,7 @@ public class PSPDFKitControllerTest {
static void testGetAttacmentDetails() {
Account act = [SELECT id FROM Account];
Test.startTest();
List <ContentDocument> conDocList = PSPDFKitController.getAttachmentDetails(act.Id);
List <ContentDocument> conDocList = NutrientController.getAttachmentDetails(act.Id);
Test.stopTest();
System.assertEquals(1,conDocList.size());
}
Expand All @@ -37,7 +37,7 @@ public class PSPDFKitControllerTest {
Account act = [SELECT id FROM Account];
ContentDocumentLink docLink = [SELECT contentDocumentId From ContentDocumentLink where LinkedEntityId=:act.Id];
Test.startTest();
Map<String,String> base64Data = PSPDFKitController.getbase64Data(docLink.contentDocumentId);
Map<String,String> base64Data = NutrientController.getbase64Data(docLink.contentDocumentId);
Test.stopTest();
System.assertEquals(3,base64Data.size());
}
Expand All @@ -48,13 +48,13 @@ public class PSPDFKitControllerTest {
ContentDocumentLink docLink = [SELECT contentDocumentId From ContentDocumentLink where LinkedEntityId=:act.Id];
Test.StartTest();
ApexPages.StandardController sc = new ApexPages.StandardController(docLink);
PSPDFKitController testAccPlan = new PSPDFKitController();
NutrientController testAccPlan = new NutrientController();

PageReference pageRef = Page.PSPDFKit_InitPSPDFKit;
PageReference pageRef = Page.Nutrient_InitNutrient;
pageRef.getParameters().put('id', String.valueOf(docLink.contentDocumentId));
Test.setCurrentPage(pageRef);

testAccPlan.getFileDetail();
Test.StopTest();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<language>en_US</language>
<protected>true</protected>
<shortDescription>Button label</shortDescription>
<value>Edit File with PSPDFKit</value>
<value>Edit File with Nutrient</value>
</labels>
</CustomLabels>
27 changes: 17 additions & 10 deletions examples/salesforce/force-app/main/default/lwc/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"compilerOptions": {
"experimentalDecorators": true
},
"include": ["**/*", "../../../../.sfdx/typings/lwc/**/*.d.ts"],
"paths": {
"c/*": ["*"]
},
"typeAcquisition": {
"include": ["jest"]
}
"compilerOptions": {
"experimentalDecorators": true
},
"include": [
"**/*",
"../../../../.sfdx/typings/lwc/**/*.d.ts"
],
"paths": {
"c/*": [
"*"
]
},
"typeAcquisition": {
"include": [
"jest"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Button_label from "@salesforce/label/c.Button_label";
import { LightningElement, api, track } from "lwc";
export default class PSPDFKitEditButtonSolution extends LightningElement {
import Button_label from "@salesforce/label/c.Button_label";
export default class NutrientEditButtonSolution extends LightningElement {
@api recordId;
@api btnColor;
@api newTab = false;
Expand All @@ -9,19 +9,19 @@ export default class PSPDFKitEditButtonSolution extends LightningElement {

renderedCallback() {
this.template.querySelector("button").style =
`background-color:${this.btnColor}`;
"background-color:" + this.btnColor;
}

openFileInNewTab() {
if (this.newTab === true) {
if (this.newTab == true) {
this.newWindow = window.open(
`/apex/PSPDFKit_InitPSPDFKit?id=${this.recordId}`,
"_blank",
"/apex/Nutrient_InitNutrient?id=" + this.recordId,
"_blank"
);
} else {
this.newWindow = window.open(
`/apex/PSPDFKit_InitPSPDFKit?id=${this.recordId}`,
"_self",
"/apex/Nutrient_InitNutrient?id=" + this.recordId,
"_self"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
<p class="heading_text">
Drop your document here, or <a class="link">browse</a>
</p>
<p class="heading_info">Supports PDF, JPG, PNG, TIF</p>
<p class="heading_info">
Supports PDF, JPG, PNG, TIF, DOCX, PPTX and XLSX
</p>
</div>
</div>

Expand All @@ -60,7 +62,7 @@

<div class="viewer">
<iframe
src="/apex/PSPDFKit_InitPSPDFKit"
src="/apex/Nutrient_InitNutrient"
style="border: none; height: 100vh"
width="100%"
></iframe>
Expand All @@ -82,9 +84,9 @@
</lightning-button-icon>
<h1 style="font-size: 22px; font-weight: bold">Salesforce Files</h1>
</div>
<c-pspdfkit-open-salesforce-files
<c-nutrient-open-salesforce-files
onpass={openVfPage}
></c-pspdfkit-open-salesforce-files>
></c-nutrient-open-salesforce-files>
</div>
</div>
</template>
Expand Down
Loading
Loading