4

Hello Guys I want to show a dynamic pdf. At first it was showing me CORS error. I solved that using DOM Sanitizer. Now it is showing me unsafe url Any Help is appreciated.

HTML Code :

  <iframe src="{{Url}}"></iframe>

TS Code : Here pdfSrc stores the dynamic generated pdf path;

 this.pdfSrc = 'http://192.168.1.183/' + this.pdfPath;
 this.Url = this.sanitizer.bypassSecurityTrustUrl(this.pdfSrc);
3

1 Answer 1

15

Finally got the solution just changed the HTML Part & TS PART AS BELOW

<iframe [src]='Url' width="100%" height="1000px"></iframe>

constructor(private sanitizer:DomSanitizer){}

this.Url = this.sanitizer.bypassSecurityTrustResourceUrl(this.pdfSrc);
Sign up to request clarification or add additional context in comments.

3 Comments

IM getting error like this ERROR Error: NG0904: unsafe value used in a resource URL context (see g.co/ng/security#xss)
yes @Arul. i am getting same error
also getting same error....glad to know it doesnt work for everyone else too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.