0

I am testing the adobe document cloud view sdk on https://www.thacherandrye.com/dinner , https://www.thacherandrye.com/the-shed , https://www.thacherandrye.com/brunch

Sometimes, the file preview is not working and all I can get on the screen is a large white space(No errors in the console). Whenever I load the page for the first time, in a browser or incognito window, the file appears on the preview but after reloading or moving to another page with a preview, the file seems to disappear. I checked for the key being wrong/expired but then it should not have loaded the file even for the first time.

Below is the Javascript code I am using for the api:

$(document).ready(function() {
        document.addEventListener("adobe_dc_view_sdk.ready", function(){ 
            var adobeDCView = new AdobeDC.View({ clientId: SOME_KEY, divId: $('#adobeDcViewId{Id}').val() });
            adobeDCView.previewFile({
                content: { location: { url: $('#hdnUrl{Id}').val() } },
                metaData: { fileName: $('#hdnFileName{Id}').val()  }
            }, 
        { 
        showDownloadPDF: $('#hdnRestrictDownload{Id}').val() !== 'true', 
        showPrintPDF: $('#hdnRestrictDownload{Id}').val() !== 'true' 
        });
        });
});

Tech stack: .net framework 4.7.2, jQuery 3.6.0

Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
Jatin
  • 1
  • 1

1 Answers1

0

I tried to help you on our forums, but I don't know if you saw my response. This line worries me:

 $('#adobeDcViewId{Id}').val()

The value that needs to be passed to divId needs to be a string, and needs to match the ID of the div element. Also, #adobeDcViewId{Id} doesn't look like a valid CSS selector to me.

Can you try changing this to a hard-coded value of the div on your site?

Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
  • Thanks for your support and sorry for the delay in response from my side. {Id} here is being replaced with some unique id in case of multiple files. For "$('#adobeDcViewId{Id}').val(), The value passed to divId should be a string that matches the ID of the div used to render", this is working fine, the val() from the input field returns the div's Id. However, issue has been resolved by adding the event listener on page load only if window.AdobeDC does not exist. document.addEventListener("adobe_dc_view_sdk.ready", previewFile()); Thanks. – Jatin Aug 21 '22 at 18:50