Skip to main content
Participant
Jul 15, 2023 8:38 AM UTC
Question

Problem: PDF Embed API dc-core loaded twice

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

54 replies

Participating Frequently
Jul 18, 2023 1:20 PM UTC

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?

Translate
Raymond Camden
Community Manager
Community Manager
Jul 18, 2023 1:32 PM UTC

@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?

 

Translate
Participating Frequently
Jul 18, 2023 3:15 PM UTC

@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.

Translate
TylerL24
Participant
Jul 17, 2023 6:41 PM UTC

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.

Translate
Raymond Camden
Community Manager
Community Manager
Jul 17, 2023 1:49 PM UTC

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

Translate
Participant
Jul 18, 2023 8:22 AM UTC

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

Translate
Participant
Jul 17, 2023 8:47 AM UTC

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

Translate