Expand my Community achievements bar.

SOLVED

PDF viewer search result does get updated.

Avatar

Level 1

The Adobe git hub examples : pdf-embed-api-samples/Viewer APIs/Search and Zoom APIs/index.js
If the search is done, it must call its callbacks. In this case, "searchCallback".  However, this doesn't get called anymore.
It used to call, but at some point it doesn't. Can someone look at this problem?
Actual code looks like this

var search = function(searchTerm) {
  viewerApis.search(searchTerm)
    .then(function(sObj) {
       searchObject = sObj;
       searchObject.onResultsUpdate(searchCallback).     // ==> This callback doesn't get called.
       .then(function(result) {
       console.log("Registered callback function with onResultsUpdate(): ", result)   // ===> This is always false
       })
     .catch(function(error) {
       console.log(error)
   });
  })
.catch(function(error) {
  var errorMsg = "";
  if(error.code === "FAIL") {
  errorMsg = "No search result found";
  } else if(error.code === "INVALID_INPUT") {
      errorMsg = "Enter valid search term";
}
  document.getElementById("search-result").style.display = "block";
  document.getElementById("searchResult-num").innerText = errorMsg;
  document.getElementById("search-result").querySelectorAll(".searchResult-btn").forEach(function(element) {
  element.style.opacity = "0.2";
  element.disabled = true;
  });
})
}

//// CALLBACK. This used to called, but no longer gets called.
function searchCallback(searchResult) {
  var currentResultIndex = searchResult.currentResult.index;
  var totalResults = searchResult.totalResults;
  var searchResultItem = document.getElementById("search-result");
  searchResultItem.style.display = "block";
  document.getElementById("searchResult-num").innerText = "Result " + currentResultIndex + " of " + totalResults;
  searchResultItem.querySelectorAll(".searchResult-btn").forEach(function(element) {
    element.style.opacity = "0.8";
    element.disabled = false;
});
}
1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @ic-menlosecurity 

 

I would suggest creating an issue on GitHub if you are facing some issues with samples.

https://github.com/adobe/pdf-embed-api-samples 

 

Also, since this is AEM Community, you could try to ask questions in the document cloud community for better answers.

https://community.adobe.com/t5/acrobat/ct-p/ct-acrobat 

https://community.adobe.com/t5/acrobat-sdk/ct-p/ct-acrobat-sdk 

 

Hope this helps!

 

Regards,

Nitesh

 

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

Hi @ic-menlosecurity 

 

I would suggest creating an issue on GitHub if you are facing some issues with samples.

https://github.com/adobe/pdf-embed-api-samples 

 

Also, since this is AEM Community, you could try to ask questions in the document cloud community for better answers.

https://community.adobe.com/t5/acrobat/ct-p/ct-acrobat 

https://community.adobe.com/t5/acrobat-sdk/ct-p/ct-acrobat-sdk 

 

Hope this helps!

 

Regards,

Nitesh

 

Avatar

Level 1

Thanks I did.
However, I used github example for easy reproduce of the problem, but it happens on the production. Can someone take a look at this problem?
To reproduce the issue,
1. Enable search api support:  "enableSearchAPIs: true"
2. launch the Adobe viewer with a proper api key with service host "

cpf-ue1.adobe.io"
3. Execute a search, then the search result callback fails to call its registered callback function.

This problem is reproduced in Adobe's github example as mentioned above.