Skip to main content
Participant
September 28, 2022
Question

Document Services API - PDF Embed API Not loading automatically without manual page reload

  • September 28, 2022
  • 2 replies
  • 829 views

Hi, I'm new to Document Services API - PDF Embed API and need some assistance, i have a web application that renders html as below, as you can see i have included the below code to embed a pdf using Document Services API, when i execute my web application workflow, after the below code is executed, the browser url changes to http://localhost:8080/qapps/hm/ViewPrintPdf?showPrintPDF=false&filename=20220803165218133_2022-09-28+18%3A06%3A51.pdf and the PDF renders automatically the very first time and the page is rendered [as expected], however on subsequent execution of my webapplication workflow the browser url changes correctly to http://localhost:8080/qapps/hm/ViewPrintPdf?showPrintPDF=false&filename=20220803165218133_2022-09-28+18%3A06%3A51.pdf however the browser does not render the pdf automatically unless i reload the page manually using browser reload button or Ctrl+R, but when i reload the page the pdf is rendered correctly, but when i restart by webapplication server, again the automatic rendering happens for the very first time and the subsequent times i need to manually reload the browser page to display the pdf, Appreciate any pointers to fix this issue

 

<html><body>
<div id="adobe-dc-view"></div>
<script src="https://documentcloud.adobe.com/view-sdk/viewer.js"></script>
<script type="text/javascript">

// Store the UI options in a constant
const previewConfig = {
showDownloadPDF: false,
showPageControls: true, //showPageControls needs to be true when showZoomControl: true
showZoomControl: true,
showAnnotationTools: false,
embedMode: "FULL_WINDOW", // embedMode includes LIGHT_BOX, FULL_WINDOW
showPrintPDF: ${showPrintPDF}
}

const saveOptions = {
autoSaveFrequency: 0,
enableFocusPolling: false,
showSaveButton: false
}
document.addEventListener("adobe_dc_view_sdk.ready", function () {
var adobeDCView = new AdobeDC.View({clientId: "40f5598045e64160babc289e96b45054", divId: "adobe-dc-view"});

// Consume previewConfig here. . .
adobeDCView.previewFile({
content:{location: {url: "https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
metaData:{fileName: "Bodea Brochure.pdf"},
}, previewConfig);

adobeDCView.registerCallback(
AdobeDC.View.Enum.CallbackType.SAVE_API,
function(metaData, content, options) {
/* Add your custom save implementation here...and based on that resolve or reject response in given format */
return new Promise((resolve, reject) => {
resolve({
code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
data: {
/* Updated file metadata after successful save operation */
metaData: {fileName: "${filename}"}
}
});
});
},
saveOptions);

});
////window.location.reload();
////window.history.forward();
showPDF('http://localhost:8080/hmstatic/pdf/20220803165218133_2022-09-13 18:56:34.pdf');
</script>
</body></html>

 

 

    This topic has been closed for replies.

    2 replies

    Participant
    January 4, 2023

    I have the same problem, it' s very wierd, hope someone will help us.

    Participant
    October 3, 2022

    This required me to reload the page and i did that using javascript with the below code

    /

     // JavaScript anonymous function
                (() => {
                    if (window.localStorage) {
    
                        // If there is no item as 'reload'
                        // in localstorage then create one &
                        // reload the page
                        if (!localStorage.getItem('reload')) {
                            localStorage['reload'] = true;
                            window.location.reload();
                        } else {
    
                            // If there exists a 'reload' item
                            // then clear the 'reload' item in
                            // local storage
                            localStorage.removeItem('reload');
                        }
                    }
                })(); // Calling anonymous function here only