Skip to main content
Participant
July 15, 2023
Question

Problem: PDF Embed API dc-core loaded twice

  • July 15, 2023
  • 14 replies
  • 10499 views

Hi,

yesterday my PDF Embed API stopped working properly for no reason.

If I load it more than once in the same page, without refreshing, it gives me the error 'index.js:44 Uncaught dc-core loaded twice'.

I didn't edit anything about it.

 

This is the code:


               <script type="text/javascript">
                var pdfurl = <?php echo json_encode($pdfUrl ?? null) ?>;
                var pdfname = <?php echo json_encode($pdfName ?? null) ?>;
                document.addEventListener("adobe_dc_view_sdk.ready", function(){
                    var adobeDCView = new AdobeDC.View({clientId: ".............", divId: "adobe-dc-view"});
                    adobeDCView.previewFile({
                        content:{location: {url: pdfurl}},
                        metaData:{fileName: pdfname}
                    }, {defaultViewMode: "FIT_PAGE", showAnnotationTools: false, showLeftHandPanel: true,
                        dockPageControls: true});
                });
               </script>
 

This is the log: 

 

index.js:44 Uncaught dc-core loaded twice
haRa @ index.js:44
__webpack_require__ @ bootstrap:19
EbfC @ AdobeDCViewBase.js:13
__webpack_require__ @ bootstrap:19
(anonymous) @ ViewSDKInterface.js:2
(anonymous) @ ViewSDKInterface.js:2
(anonymous) @ ViewSDKInterface.js:2

 

Any suggestions gratefully received.

Cheers, Daniel

14 replies

Participating Frequently
July 18, 2023

I am also seeing this, I utilize the embed on an LMS, and have the core loading each time an embed is on a page, if i have subsequent pages that i move through it stops loading properly and a refresh must occur for it to display, am wondering if a variable could be set to check if the core is already loaded first before it try's a second time?

Raymond Camden
Community Manager
Community Manager
July 18, 2023

@CSumner102 You can check for window.AdobeDC.

@TylerL24 Your comment - are you ONLY talking about cases where the script tag is loaded twice? If not, please open a new thread.

@Crew31128935gi26 So do you get the error with 2 + embeds, even if you have 1 script tag?

 

Participating Frequently
July 18, 2023

@Raymond Camden yes i was getting the dc-core loaded twice in the console, I just edited my code to this

 

<script type="text/javascript">
  function initializeAdobeDCView() {
    var adobeDCView = new AdobeDC.View({clientId: "Your ID", divId: "adobe-dc-view"});
    adobeDCView.previewFile({
      content: {
        location: {url: "Your File URL"}
      },
      metaData: {fileName: "Your File Name"}
    }, {
      embedMode: "FULL_WINDOW",
      defaultViewMode: "FIT_WIDTH",
      showFullScreen: true,
      showAnnotationTools: false,
      showZoomControl: true,
      focusOnRendering: true,
      showDownloadPDF: true
    });
  }
  function loadViewerScript() {
    if (window.AdobeDC && window.AdobeDC.View) {
      initializeAdobeDCView();
    } else {
      var viewerScript = document.createElement('script');
      viewerScript.src='https://documentservices.adobe.com/view-sdk/viewer.js';
      viewerScript.onload = initializeAdobeDCView;
      document.body.appendChild(viewerScript);
    }
  }
  loadViewerScript(); // Load the Adobe DC View SDK and initialize the viewer
</script>

 

and now it checks to see if the core is already loaded before it try's to again.

TylerL24
Participant
July 17, 2023

I have been having the same issue since the 14th as well.  Most of my larger PDFs with annotations do not load.  I have tested it with samller image based PDF files and those have been able to load.  Been attempting to troubleshoot but have not found a resolution yet.

Raymond Camden
Community Manager
Community Manager
July 17, 2023

Does the error go away if you have the script tag only once on your page? I mean the one loading the library.

Participant
July 18, 2023

Tried this but no luck, either doesn't load and no error or doesn't load and errors.

Participant
July 17, 2023

We're getting the same issue, nothing changed on the server just started happening.