Save PDFs to Salesforce from a Lightning Web Component

Currently, you can save files back to Salesforce if one of the following conditions is satisfied:

  • The file is a PDF that you opened using the built-in user interface (UI) from your local machine or Salesforce.

  • The file is a PDF that you opened programmatically from Salesforce.

You can save files to Salesforce that are smaller than 25 MB.

For more information on uploading documents to Salesforce, see the Salesforce documentation.

Save a file back to Salesforce in one of the following ways:

Saving Files Using the Built-In UI

To save a file back to Salesforce using the built-in UI, follow these steps.

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

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

  3. Search for and select PSPDFKit.

Search for PSPDFKit in the quick find box in your organization

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

PSPDFKit tab in Salesforce environment

  1. Make changes to the document.

  2. In the top-right corner, click Save.

Saving Files Programmatically

Before continuing, perform all of the following actions:

  • If you’ve deployed PSPDFKit for Salesforce to an existing project, ensure that you added the PSPDFKit file selector Lightning web component to your project.

  • Ensure you’re logged in to Salesforce as a user authorized to use PSPDFKit.

To save a file back to Salesforce programmatically, follow these steps.

  1. Open the Salesforce file programmatically.

  2. In your text editor, open the PSPDFKit_InitPSPDFKit.page Visualforce page within the force-app/main/default/pages folder.

  3. Change the PDF file programmatically using the capabilities of the PSPDFKit for Salesforce SDK. For example, add an annotation.

  4. After making the changes, call the saveFileToSalesforce() method.

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

sfdx update
sfdx org:login:web --alias mySalesforceOrg --instance-url https://login.salesforce.com --set-default
  1. In the browser window that opens, log in to your Salesforce organization and authorize the Salesforce CLI.

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

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