Run without Viewer in Salesforce
Apryse's SDK provides full viewing of documentation formats and other capabilities but also provides access to Apryse's PDFNet SDK that allows document operations excluding a UI if necessary.
This is useful for Salesforce that needs additional processing without viewing a document. Although there are performance drawbacks as this is done on the client-side, it can be critical as part of your app's flow.
Here is a sample no-viewer Salesforce to follow with this guide:
Prerequisites
This guide assumes you will have downloaded WebViewer SDK and have Webviewer running on your Salesforce org.
If you have not done so, please check out the following to get started:
1. Create a hidden LWC
Webviewer still needs to be present on the page of your Salesforce org. You will need to create a lightning web component that has a hidden div to hold the iframe that would run no-viewer Webviewer.
<template>
<div id="core-controls-iframe" class="slds-hidden" lwc:dom="manual"></div>
</template>WebViewer Core is the core for WebViewer. The usual script that would be required with the UI is webviewer.min.js. Using this script would automatically import and use the core.
webviewerConstructor is similar to custom tag in a Webviewer constructor, pass information through the iframe src and hash the information from the url in the config file. Set the iframe to take up no space in the lwc if you want a true no-viewer page. Create an iframe to host an html file that runs script tags pathed to webviewer.core.min.js and PDFNet.js
2. Setting the worker path
In a viewer-less scenario, we would only import the core script (webviewer-core.min.js; CoreControls.js prior to WebViewer 8.0) in the HTML, if needing the FULL api you need to reference a different script(PDFNet.js) also.
WebViewer requires web workers to function and work with documents. This is necessary regardless of the setup. Normally, this is done automatically via the path option in the WebViewer constructor. In a viewer-less scenario, we can load the workers with a simple JavaScript call:
3. Usage
Once the workers are ready, everything is in place to use the APIs and classes in the Core namespace.
Communicate with Salesforce
Often in Salesforce, sending information to our workers is common so having a communication method to recieve and send out information is required.
Building a custom UI
One special use case would be to create your own UI by leveraging the DocumentViewer class and object.
Processing documents (Full API - PDFNet)
Another use case is to use the APIs to process documents in the client (browser). We already establish Full API usage so now we just have to test them.
Last updated
Was this helpful?