Load Local file

Hi

How can I load local file in pdf-viewer Like you loading in your DEMO. It showing me below error.

XMLHttpRequest cannot load file:///home/shabbir/Desktop/20-0226-02FMBS.nagar.pdf. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

1 possible answer(s) on “Load Local file

  1. This is an example

    // in template <pdf-viewer [src]="previewSrc" ...
    // var yourFile = File Object
    
    let reader = new FileReader();
    
    reader.onloadend = (e: any) => {
       this.previewSrc = e.target.result;
    };
    
    reader.readAsArrayBuffer(yourFile);