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

satyanarayanm67847935
Participating Frequently
April 2, 2024

Any update on this yet, I am also facing the same issue.

 

Participant
April 27, 2024

Not sure how relevent this is, but while I was trying to delete the script element I noticed that it's parentNode is null and as per my reading that could be an issue with the library?

Participant
December 19, 2023

Has anyone figured out a way to get rid of this issue?

The PDF I have embedded in my NextJS app doesn't load with navigation(i.e., If I go back and come again to that page, the pdf is not showing). It shows when I reload that page. I don't get the 'dc-core loaded twice' error, however.

Raymond Camden
Community Manager
Community Manager
December 19, 2023

Embed can absolutely be used in a SPA, but I'd have to see your code to help diagnose what the issue may be, or at least know if you see something in the console. 

Participant
February 1, 2024

@Raymond Camden Would you mind looking at my repo demonstrating this issue w/ a Next.JS SPA, shared earlier in this thread?

Thanks!

juanjullian
Participant
November 14, 2023

Hi, when you close or hide the pdf viewer, also do: 

window.AdobeDC = undefined; 
window.adobe_dc_sdk = undefined; 
window.adobe_dc_view_sdk = undefined; 

after that you can load the viewer again without trouble

Participant
December 29, 2023

window.AdobeDC = undefined;
window.adobe_dc_sdk = undefined;
window.adobe_dc_view_sdk = undefined;
var adobe_sdk = document.createElement('script');
adobe_sdk.setAttribute('src','https://documentcloud.adobe.com/view-sdk/main.js');
document.head.appendChild(adobe_sdk);

Participant
October 12, 2023

@Raymond Camden 
I''ve created a minimal repo that demonstrates this issue (or something close to it) in Next.JS:
https://github.com/HolySamosa/adobe-dc-view-isssue

Interestingly, w/ this example in Chrome I'm not seeing the dc-core loaded twice error message, however I still see the same behavior w/ only the initial instance of the PDF component rendering.  When running in an embedded Safari webview on the iOS simulator, we do see the dc-core loaded twice message.  

Participating Frequently
September 28, 2023

I have some updated code that I am now using, this was because in certain use cases, I was still getting an error.

the new code waits for everything to load and it then checks if it needs to load the dc core. Hope this helps somebody...

 

<script type="text/javascript">
  function initializeAdobeDCView() {
    var adobeDCView = new AdobeDC.View({clientId: "Your Token", divId: "adobe-dc-view"});
    adobeDCView.previewFile({
      content: {
        location: {url: "URL"} // URL to your Adobe PDF File
      },
      metaData: {fileName: 'Filename'} // The name you wish the file to have when downloaded
    }, {
      embedMode: "FULL_WINDOW",
      defaultViewMode: "FIT_WIDTH",
      showFullScreen: true,
      showAnnotationTools: false,
      showZoomControl: true,
      focusOnRendering: true,
      showDownloadPDF: true
    });
  }

  function loadViewerScript() {
    if (window.AdobeDC && window.AdobeDC.View) {
      setTimeout(initializeAdobeDCView, 100); // Delay the call to ensure the SDK is loaded
    } else {
      var viewerScript = document.createElement('script');
      viewerScript.src='https://acrobatservices.adobe.com/view-sdk/viewer.js';
      viewerScript.onload = function() {
        setTimeout(initializeAdobeDCView, 100); // Delay the call to ensure the SDK is loaded
      };
      document.body.appendChild(viewerScript);
    }
  }

  loadViewerScript(); // Load the Adobe DC View SDK and initialize the viewer
</script>

 

Participant
October 10, 2023

We're seeing the same issue as described in a Next.JS app.  Everything had been working fine until sometime within the last 2-3 months (but we just gort the bug report).  I'll try the work-arounds suggested and will monitor this thread.  Thanks for the help.

Participant
September 28, 2023

We're facing the same problem/error. It worked great until something changed on Adobe's side. It's hard to make a reproducable case when you have a full-fledged web app that relies on other things to even remotely reproduce this in another environment. If it provides any insight, in my case, this error is occuring when an initial PDF is loaded on the page, but a new one is retrieved and attempts to replace the old one - which as mentioned, worked perfectly fine up until a month or so ago and nothing has been changed with our code.

Participating Frequently
September 7, 2023
document.addEventListener("adobe_dc_view_sdk.ready", function () {
window.adobe_dc_sdk['dc-core-loaded'] =false ;
... 
}, not the best solution but that can help yous 
Raymond Camden
Community Manager
Community Manager
September 7, 2023

Actually, you can look for window.AdobeDC. We set that when initialized. 

Participant
August 7, 2023

Same issue here. Can we get a reply on this thread ASAP as we have client deliverables that are at risk because of this bug. 

Raymond Camden
Community Manager
Community Manager
August 7, 2023

I have been replying, @Tim31535141jsgj As I said, I need a reproducable case I can run locally to confirm. I'll then file a bug report.

German5FFC
Participating Frequently
August 3, 2023


I thought the problem was with the script tag that we have to add in our html, but I'm seeing another script related to adobe being added. I'm noticing that the ViewSDKInterface.js is being added twice.

Raymond Camden
Community Manager
Community Manager
August 3, 2023

Ok, again though, I really need some way to test this myself locally. If you can help me with a minimal repro I can run, I'll confirm and log.

germanf90111513
Participant
August 1, 2023

Is there any official solution to this? I'm having the same problem 😞

Raymond Camden
Community Manager
Community Manager
August 1, 2023

I'm struggling to understand how to replicate it. You say, load it more than once. What do you mean by that? You can definitely do 2+ PDF Embed on one page. If you mean the script tag, you should only be adding that once per page.

Raymond Camden
Community Manager
Community Manager
August 1, 2023

I just now noticed this is page 2 of the issue I was helping out before. Looks like my last reply was basically asking for a repro. I _still_ need that, something that's HTML based, no PHP etc, and as simple as possible so I can repro and file a report.