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.
-
Ensure you’re logged in as a user authorized to use PSPDFKit.
-
In the top-right corner, open the App Launcher.
-
Search for and select PSPDFKit.
-
Click browse to upload local PDF files, or open a file from Salesforce.
-
Make changes to the document.
-
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.
-
In your text editor, open the
PSPDFKit_InitPSPDFKit.page
Visualforce page within theforce-app/main/default/pages
folder. -
Change the PDF file programmatically using the capabilities of the PSPDFKit for Salesforce SDK. For example, add an annotation.
-
After making the changes, call the
saveFileToSalesforce()
method. -
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
-
In the browser window that opens, log in to your Salesforce organization and authorize the Salesforce CLI.
-
In the terminal, run the following command from the PSPDFKit for Salesforce project’s root folder:
sfdx force:source:deploy -x manifest/package.xml