WebViewer Version:
8.6.0
Do you have an issue with a specific file(s)?Pdf, Docx
Can you reproduce using one of our samples or online demos?No
Are you using the WebViewer server?No
Does the issue only happen on certain browsers?No
Is your issue related to a front-end framework?No
Is your issue related to annotations?No
Please give a brief summary of your issue:
I integrated Webviewer for Salesforce following the steps mentioned in the video but after deploying the static resources and lwc to the scratch org, Iâm unable to use Webviewer . I canât view pdf files . It throws an error in portal : Worker encountered an error and in console I can see that it says Error: Failed to find PDF worker files. This project is not set up to work with PDF files.
Please describe your issue and provide steps to reproduce it:
The issue is that I canât use any of PdfTronâs feature because the file doesnât load. It works when I upload a jpg or png file but they canât be redacted or downloaded. I followed the steps in the Salesforce integration guide video.
Attaching link of the video showing the issue : pdftron.mp4
The errors you are seeing in your video are related to WebViewer not being able to locate PDF worker files which are required for rendering/redaction of your document.
To debug this, please check the Network tab in your browser console (you might need to refresh to see all requests). You should see some failed requests (status code 404) - please click on them and see what the request URL is. Make sure that your static resources includes the requested URL. If the resources are not uploaded, make sure to add them to static resources.
Also, make sure you check the request URL for /lean/ or /full/ which indicates full or lean API. You can set fullAPI to true or false in the WebViewer constructor of your LWC component, and need to make sure the corresponding resources are available (ie when settin fullAPI: true, make sure you generate the workers in the NPM script and answer y to fullAPI).
Hope that helps, let us know if you have any other questions.
Hi @twinter yeah the path set was incorrect. Itâs now working as expected. Just a thing , can we view Salesforce attachments using PDFTron webviewer. If yes , can you please guide me through the steps
I am able to search for related attachments in an Object Record. This will probably be my last query. Can we apply redactions programmatically such that when a document is opened in Webviewer , it is actually redacted automatically.
Use the exported XML String and save it in a custom object / custom metadata. Then when loading a document, look for any associated annotations and automatically load them the same way it is described here: PDFTron Systems Inc. | Documentation (check the getAnnotations() method in Apex)
Hi @twinter , I am looking for redaction automation . I want to redact certain regex matching text from document without storing anything in Custom Objects( have a restriction on creation of Custom Object). Is there a way I can actually set a regex which would redact the document automatically when it loads
Sure, the text search has support for regex. In the previous answer (Option 2) you can see how to do a text search. That API supports regex (see here, you just need to pass { regex: true } to the search call: PDFTron WebViewer Namespace: UI )
So for your use case, I would add a callback function in your config.js file for documentLoaded event, perform a call to seachTextFull('your regex here', { regex: true}), use a searchListener to mark any matches for redaction (this will draw redaction rectangles over all search results). If you wish to apply the redactions right away make a call to applyRedactions() on AnnotationManager: PDFTron WebViewer Class: AnnotationManager