How to enable Layers (OCGs) in Salesforce

I have PDFTron integrated with my Salesforce org and I have a requirement for enabling the layers functionality.
I have set the fullAPI and forceClientSideInit properties as true during instantiation in the LWC component.
Unfortunately, in the config.js file, in the “documentLoaded” event handler when I try to call the getLayersArray i.e. execute “readerControl.docViewer.getDocument().getLayersArray()”, the promise does not resolve or reject, even though the uploaded PDF has layers.

Hi @Wanbo_Li / team could you please assist on this?


Thanks for your post! I just ran the following in Salesforce using WebViewer v8.8.0:
let layers = await documentViewer.getDocument().getLayersArray() and was able to log the layers in the document (see screenshot).

Looks like you are using version 7.x.x based on your code snippet - could you try the following and let me know if that works for you:

window.addEventListener('documentLoaded',  async () => {
   let layers = await readerControl.docViewer.getDocument().getLayersArray();


Hello Twinter,

Thanks for the response!

Unfortunately, in my case the code execution stops at the await as there is no fulfilled promise.

PS: There is an error though in the console everytime I reload any document. Not sure if its relevant to this issue.

What version of WebViewer are you using? It should be listed in your browser console upon viewer load.


PFB the specs


Hi Romit,
Thanks for sending me the version number. I just ran a test and was able to get the layers using the same code as stated above on version 7.3:

Based on these findings, I’m wondering if the error is related to you setting fullAPI: true - this requires the pdf_full and asm_full worker files (zip files in your staticresources folder).

Please check your network tab and look for any 404’s - if there is a worker file mismatch you will probably see a failed request to under your network requests. If that’s the case, you need to upload the appropriate workers to staticresources.

You can review this video if you need help with generating worker files for Salesforce (make sure you select y to the Do you need the fullAPI? prompt): Download WebViewer SDK & Optimize for Salesforce Deployment - YouTube

If you need to download 7.3 again you can find it here: PDFTron Systems Inc. | Download-center

Let me know if that works, happy to set up a call to get you some help.


Hi Thomas,

These are two 404’s pertaining to the worker files:

I downloaded WebViewer- 7.3.3 and replaced the contents of my resource static resource with the following files from the WebViewer- 7.3.3 . But still, its giving 404 response.

PS: Is the layers functionality, as depicted in the demo/sample out of the box? Or do we need to implement it?
In my case, the layers panel is blank, even though I’ve activated it.


Hi Romit,

The layers functionality should be available in the UI out of the box. I’m thinking since you are still facing 404’s, that there is a worker mismatch or something else happening (possibly related to how Salesforce cache works).

Happy to help you with this, you could book an office hour with myself here: Calendly - Thomas Winter - and we can jump on a quick screen share to debug and get it working.