Skip to main content
Participant
Nov 23, 2022 8:46 AM UTC
Question

File preview error

Hi, we are facing a similar error. We see the same 'File preview error' in browser and we see CORS error in console as follow: -

Our code looks like as follow: -

readyPromise: Promise<any> = new Promise((resolve) => {
    if (window.AdobeDC) {
      resolve('');
    } else {
      document.addEventListener('adobe_dc_view_sdk.ready', () => {
        resolve('');
      });
    }
  });

previewFile(divId: string, documentUrl: string) {
    const config: any = {
      clientId: '548463e49415464db30c3eea90b757fd',
    };
    if (divId) {
      config.divId = divId;
    }
    this.adobeDCView = new window.AdobeDC.View(config);

    const previewFilePromise = this.adobeDCView.previewFile({
      content: {
        location: {
          url: 'https://secure.eu1.adobesign.com/document/cp/3AAABLblqZhAnnaCqNZcTFsYRHPJjIGS6IJiY6aGNHtpJ21P-AkJNdvQue_M5bDRKtTGcbIuYUnM-E70FsHemg3CZ_miEqxNv/document.pdf'
        },
      },
      metaData: {
        fileName: 'DemoFile.pdf',
      }
    }, {
      showAnnotationTools: false,
      showLeftHandPanel: false
    });

    return previewFilePromise;
  }

Kindly help. We are relatively new and stuck at this.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    Legend
    Nov 23, 2022 9:13 AM UTC

    If you don't want to get into the complicated world of CORS, you must have the link and the PDF on the same domain. 

    Translate
    Participant
    Nov 23, 2022 9:34 AM UTC

    @Test Screen Name  Hey but this is our use case 😞 Any suggestions for this?

    Translate
    Legend
    Nov 23, 2022 10:47 AM UTC

    Ok, then you need to set up CORS correctly. By default, one domain cannot load items from a different domain. This is very important web security, designed to protect from impersonation.

    Translate