Reputation: 1047
I just want to show a PDF that is found within the project directory.
I did read the online documentation render-local-pdf-file but still, I was not able to make this work.
Here is my code:
import { Component } from '@angular/core';
@Component({
selector: 'app-message',
templateUrl: './message.component.html',
styleUrls: ['./message.component.scss'],
})
export class MessageComponent{
src: string = '../confirmation.pdf';
}
and here is how I implemented it within the template
<pdf-viewer [src]="src" style="display: block;">
</pdf-viewer>
If I use the pdf found in the example ("https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf") the viewer works.
Why does it make a difference if I use a local file agains an URL for the PDF?
The error I am getting is the following:
404 Not Found XHR GET http://localhost:4200/confirmation.pdf
The file is found one level above the message component:
confirmation.pdf
- message
- message.component.html
- message.component.ts
Upvotes: 1
Views: 3186