2 thoughts on “URL scheme “file” is not supported.

  1. For future readers.

    I stumble upon this problem today. I was using v1.2.x just loading the local url file straight forward but since 2.x.x , @VadimDez started using Fetch api which doesn’t support ‘File’ scheme eg: ‘file:///my-file.pdf’

    Here’s my curently workaround:

    async loadPdf(path: string) {
      return new Promise<string>((resolve, reject) => {
    
        const request = new XMLHttpRequest();
        request.open('GET', path, true);
        request.responseType = 'blob';
    
        request.onload = () => {
          const reader = new FileReader();
    
          reader.onload = (e: any) => resolve(e.target.result);
          reader.onerror = err => reject(err);
          reader.readAsDataURL(request.response);
        };
    
        request.send();
      });
    }
    
    // ...
    this.pdfSrc = await this.loadPdf('file:///path/to/file.pdf');

    I’m building a desktop app (Electron+Angular)