Automatic Redaction Search

I’m trying to get the webviewer to do a redaction search whenever you load a document. I found two different ways to do this in the code below, but in both the results only show up in the search panel. Is there a way to get the results to also show up in the redaction panel?

        documentViewer.addEventListener('documentLoaded', () => {
          if (searchTermOnLoad) {
            //Option 1
            const mode = instance.Core.Search.Mode.REGEX | instance.Core.Search.Mode.WILD_CARD | instance.Core.Search.Mode.HIGHLIGHT | instance.Core.Search.Mode.AMBIENT_STRING;
            documentViewer.textSearchInit(searchTermOnLoad, mode, {
              fullSearch: true,
              onResult: (result: { resultCode: number; quads: { getPoints: () => any; }[]; pageNum: any; }) => {
              startPage: 1});
            //Option 2

Hi Kanderson,

Thank you for contacting us regarding Webviewer.

I’ll inquire the information from the team and get back to you as soon as possible.

Ok, great. Thank you!

Hi Johnny,

Do you have any updates on this? I heard from a co-worker that the Redaction Search API is not public yet, so I’m guessing this won’t be possible until then. Do you know when that API will be made public?

Hi Kanderson,

sorry for the late reply. I have confirmed that we currently don’t have an API to do so.

We don’t currently have this on our roadmap but, we will add it to the backlog for our product team to review for feasibility and viability.

If you could provide some further information around the context of why you want the feature, this may help prioritize its development. We would be interested to know:

  • What is the workflow that you would use the requested feature in?
  • Why is the feature valuable to you and your users?
  • How are you coping without it right now?

Hi Johnny, thanks for confirming. For some background, I’m from Real Life Sciences and we’re developing an application where users can search documents for sensitive information and redact it. So the search tab isn’t very useful for our users because you can’t add redactions from there or search using patterns.

Having control over the redaction search would be really useful for us in a lot of ways. The specific feature I’m trying to add now is searching across more than one document. So if a user has two documents open and they do a redaction search on the active document and then go to the other document, we want it to do the same redaction search as soon as the other document loads.

Thanks for your time, I really appreciate you listening to our feedback.

Hi Kanderson,

sorry for the late reply as I was on vacation last week.

Looking at our demo: JS PDF Redaction Demo | Apryse WebViewer, is this what you’re looking for? (applying redaction to the search result, so they would be shown in the redaction panel)

Hi Johnny, no worries. I may be missing something but that demo doesn’t do what we need. What I’m trying to implement is this workflow:

-User can two documents open in the webviewer (doc1 and doc2)
-User searches for “age” in the redaction tab when looking at doc1. Search results appear on the redaction tab.
-User clicks on doc2. As soon as doc2 loads, the system should automatically search for “age” and display the search results on the redaction tab.

Hi Kanderson,

Thank you for providing the information.

When you say open two documents in Webviewer, are you referring to the multi-tab function?

If so, what I can think of is to store “age” in local storage after you search it in doc1, then in the document loaded event you would need to programmatically search it again. The code snippet would be similar to

const { documentViewer } = instance.Core;

documentViewer.addEventListener('documentLoaded', () => {
    const searchInput = localStorage.getItem('...');
    if (searchInput) {
      // then search the text and apply redaction to all the results

Please let us know if this resolves your issue, thank you.

Hi Johnny,

Yeah, I’m trying to get this to work with the multi-tab function. I figured out how to store the search term and then run a search when the document is loaded. The problem is the search results appear in the search tab, but I want them to appear in the redaction tab. If there’s any way to get them to appear in the redaction tab, let me know. But it sounds like that’s not available right now. If that’s true, then that answers my question. Thanks for taking the time to look into this.

Hi Kanderson,

Please check the following code snippet to see if this resolve your issue:

documentViewer.addEventListener("documentLoaded", () => {
  // search text first
  // get the result's information 
  const resultsOnCurrentPage = instance.Core.documentViewer.getPageSearchResults(pageNumber);
  // there's a quads property that shows the four coordinates point, we will use this quads to draw redact annotations
    const redactAnnot1 = new Annotations.RedactionAnnotation({
        PageNumber: 1,
        Rect: new Annotations.Rect(100, 100, 300, 200) // Rect are in the form x1,y1,x2,y2, which comes from previous information.
  // after drawing, this should be shown in the redaction panel. The redaction panel should be opened as well

Yeah, that will work for now. I’ll mark that as the solution.

Just to be clear though, that will add the search results to the document as redactions. What I was asking for is to display them as search results on the redaction panel as in this screenshot. That would be a great feature for us to have in the future. It would be useful for our users because they may want to review the search results before actually adding them as marks.

Thanks for you patience through all of this! My team is still working out the best way to implement our workflow in the webviewer.