Some test text!

menu
Overviewkeyboard_arrow_down

Integrating WebViewer Into a Salesforce Lightning Web Component

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:

linkConfig.js

The WebViewer deployment in Salesforce requires that any extended logic be placed into the config.js file.

Additional reading about config.js

linkEquivalent of the Instance Callback Parameter

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

linkCreating a Rectangle Programmatically

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);
});

linkHiding Elements of the UI

The original guide can be found here

// config.js
window.addEventListener('viewerLoaded', async () => {
  readerControl.disableElements([ 'leftPanel', 'leftPanelButton' ]);
});

Guides

linkOpening a Document Saved In Salesforce

Opening and Saving Documents In Salesforce

Get the answers you need: Support

close

Free Trial

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.

Unlimited usage. No email address required.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close