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:
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.
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
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:
You can check out the full guide on how to build your own UI .
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.
1async function main() {
2 // creates an empty pdf document (PDFDoc)
3 const doc = await PDFNet.PDFDoc.create();
4 doc.initSecurityHandler();
5 // Locks all operations on the document
6 doc.lock();
7
8 // insert user code after this point
9 const pgnum = await doc.getPageCount();
10 alert(`Test Complete! Your file has ${pgnum} pages`);
11};
12
13PDFNet.runWithCleanup(main, /* License key goes here after purchase */)