View pdf from remote link

in Your .ts file use this code.

import { DomSanitizer} from '@angular/platform-browser';

@Component({
  ...
})
export class XYZ {
    pdfLink:any;
    constructor(private sanitizer: DomSanitizer) {
        this.pdfLink = this.sanitizer.bypassSecurityTrustResourceUrl('http://docs.google.com/gview?embedded=true&url='+YOUR_PDF_URL_GOES_HERE);
    }
}

in your HTML file


<iframe *ngIf="pdfLink" [src]="pdfLink" width="100%" height="100%" frameborder="0" ></iframe>
6 Likes