Skip to main content
Participant
August 16, 2022
Question

Issue with adobe_dc_view_sdk preview

  • August 16, 2022
  • 1 reply
  • 540 views

Testing the preview 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 browser 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. I have looked into some community discussions but nothing seems to be helpful.

Below is the Javascript code I am using for the api:
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>

 

$(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


Please Help!
Thanks

This topic has been closed for replies.

1 reply

Raymond Camden
Community Manager
Community Manager
August 16, 2022

This part, divId: $('#adobeDcViewId{Id}').val(), concerns me. The value passed to divId should be a string that matches the ID of the div used to render. The CS celestor you used, adobeDcViewId{Id}, doesn't look like a valid selector. Is it? And if so, I assume it points to a form field such that .val() works and returns a string. 

Participant
August 21, 2022

Thanks for your support and sorry for the delay in response from my side.
{Id} here is being replaces with some unique id incase 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.