Frameworks
Integrations
Mendix
SharePoint
Modular UI
Legacy UI
AnnotationManager
Annotation Types
Customize
Version 11
Version 10
v10.12
v10.11
v10.10
v10.9
v10.8
v10.7
v10.6
v10.5
v10.4
v10.3
v10.2
v10.1
v10.0
Version 8
v8.12
v8.11
v8.10
v8.9
v8.8
v8.7
v8.6
v8.5
v8.4
v8.3
v8.2
v8.1
v8.0
Version 7
Version 6
v6.3
v6.2
v6.1
v6.0
Version 5
Version 4
Version 3
Version 2
WebViewer Server
WebViewer BIM
A common workflow in WebViewer is a programatic search and redact - search a document for text and permanently removing it from the document.
There are four steps involved in setting up this workflow. This guide will walk you through each step and explain the core concepts in setting up this workflow.
As mentioned in the setup redaction guide, there are a few parameters you need to pass to the WebViewer constructor to get redaction working. The two properties are fullAPI
and enableRedaction
.
In your WebViewer constructor call, ensure you are setting both those properties to true
.
Once redactions are enabled, we can begin implementing our workflow by searching for the text we want to redact. The easiest way to do this is using the textSearchInit
API.
This API accepts a string or a regex to search for, as well as some additional options and callbacks.
Using the textSearchInit
function looks like this:
There are a few main parts to look at here.
The mode
parameter sets the search mode. There are many different options here, and you can set one or many search modes by passing them as an array. For example, if you wanted to use a wildcard ("*") in your search pattern, you would have to append the WILD_CARD
mode like so:
The searchOptions parameter lets you provide a set of callbacks and additional options for your search. A full list list of all the options can be seen here. In this workflow, we care about fullSearch
, onResult
, and onDocumentEnd
.
You can also search for text using a regular expression by setting the REGEX
search mode and passing in a regex expression as your search query. This would look something like this:
Now that we have our search code implemented, we can use the results of that search to programmatically create redaction annotations. This process involves using the onResult
callback and using the result
object to get the coordinates of the text we want to redact. Using these coordinates, we can place a redaction annotation on the document.
The implementation will look something like this:
At this point, you should be able to search for text and place a redaction annotation on top of all the results. The last step is to apply those redactions to permanently remove the text from the document.
At this point we have only placed redaction annotations on the document and have not actually removed the content from the underlying document. To do the actual content removal, we need to "apply" the redactions.
To do this, we can call the annotationManager.applyRedactions
API, passing in all the redactions we created in step 3.
We want to do this after the search is complete, so we can add the code into the onDocumentEnd
callback.
After calling the above code, the redactions should be applied to the underlying document and the text you searched for should be permanently removed!
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales