Ng2-pdf-viewer Access-Control-Allow-Origin

I am using ng2-pdf-viewer library for Angular and I am trying to display a PDF from the main url. the problem is I am getting the following error:

XMLHttpRequest cannot download https://www.bbv.ch/images/bbv/pdf/Publikationen/BBV16Poster_Angular2.pdf . There is no "Access-Control-Allow-Origin" header in the requested resource. Origin ' http: // localhost: 54800 ' is therefore not allowed access.

Here is my code:

.ts:

{ Name: "Angular2 tuto", Description: "An amazing Angular2 pdf !", Url: {url: "https://www.bbv.ch/images/bbv/pdf/Publikationen/BBV16Poster_Angular2.pdf", withCredentials: true} }

      

.html:

<pdf-viewer [src]="document.Url" [page]="1" [original-size]="false" style="display: block;"></pdf-viewer>

      

I tried with and without the "withCredentials" property - nothing changed ..

How can I show any pdf from a link in angular2? (worked in a basic iframe though ...)

+3


source to share





All Articles