I'am trying to open a .pdf file in local storage using an iFrame. Code I tried is as follows.
In HTML file
<object [data]="sanitizer.bypassSecurityTrustResourceUrl(selectedItem.FilePath)" type="application/pdf">
<iframe [src]="sanitizer.bypassSecurityTrustResourceUrl(selectedItem.FilePath)">
</iframe>
</object>
in Component.ts file
import { DomSanitizer } from '@angular/platform-browser';
this.selectedItem.FilePath="D:\WorkDir\Exceline\US.Exceline.GMS\US.Common.Web.Web\DocumentStore\beta\1\145\pdf.pdf"
without the sanitizer it will throw an exception as follows.
ERROR Error: unsafe value used in a resource URL context (see
http://g.co/ng/security#xss)
at DomSanitizerImpl.webpackJsonp.../../../platform-
browser/@angular/platform-browser.es5.js.DomSanitizerImpl.sanitize
(platform-browser.es5.js:3970)
at setElementAttribute (core.es5.js:9320)
at checkAndUpdateElementValue (core.es5.js:9291)
at checkAndUpdateElementInline (core.es5.js:9238)
at checkAndUpdateNodeInline (core.es5.js:12325)
at checkAndUpdateNode (core.es5.js:12271)
at debugCheckAndUpdateNode (core.es5.js:13132)
at debugCheckRenderNodeFn (core.es5.js:13111)
at Object.eval [as updateRenderer] (McDocumentsComponent.html:110)
at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:13096)
With sanitizer it won't open the file. What am I doing wrong ? How can I open a .pdf file in the local server. ?