Some test text!
Many of the Web guides you will find about how to extend WebViewer to fit your needs is applicable to a Salesforce deployment, though there are some key differences to be aware of:
The WebViewer deployment in Salesforce requires that any extended logic be
placed into the config.js
file.
Additional reading about config.js
Most of the WebViewer examples will assume access to the instance
callback
parameter:
WebViewer(
// ...
)
.then(instance => {
// instance will be undefined in a Salesforce deployment!
});
In a Salesforce deployment, the equivalent of instance
is readerControl
.
Here are some examples from our guides translated to a Salesforce deployment
The original guide can be found here
// config.js
window.addEventListener('documentLoaded', async () => {
const { docViewer } = readerControl;
const annotManager = await docViewer.getAnnotationManager();
/**
* Global namespace is accessible from config.js, hence why `Annotations` does
* need to be de-structured from readerControl
*/
const rectangleAnnot = new Annotations.RectangleAnnotation();
rectangleAnnot.PageNumber = 1;
// values are in page coordinates with (0, 0) in the top left
rectangleAnnot.X = 100;
rectangleAnnot.Y = 150;
rectangleAnnot.Width = 200;
rectangleAnnot.Height = 50;
rectangleAnnot.Author = annotManager.getCurrentUser();
annotManager.addAnnotation(rectangleAnnot);
// need to draw the annotation otherwise it won't show up until the page is refreshed
annotManager.redrawAnnotation(rectangleAnnot);
});
The original guide can be found here
// config.js
window.addEventListener('viewerLoaded', async () => {
readerControl.disableElements([ 'leftPanel', 'leftPanelButton' ]);
});
Get the answers you need: Support
Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.
Select a platform to get started with your free trial.
Web
Android
iOS
Windows
Linux
Unlimited usage. No email address required.