I'm trying to use the ng2-pdf-viewer component to display several PDFs from my ASP.NET Web API backend. I've added PdfViewerComponent to my module's declarations and the provided example works fine:
import { Component } from '@angular/core';
@Component({
selector: 'example-app',
template: `
<div>
<label>PDF src</label>
<input type="text" placeholder="PDF src" [(ngModel)]="pdfSrc">
</div>
<pdf-viewer [src]="pdfSrc" [render-text]="true" style="display: block;">
</pdf-viewer>
`
})
export class AppComponent {
pdfSrc: string = '/pdf-test.pdf';
}
The problem arise when I try to load the pdf src from my any other resource.
I first encountered CORS issues, but I later resolved this with the DomSanitizer. The new error I get whenever I try to load PDFs are:
ERROR Error: Invalid parameter object: need either .data, .range or .url
at Object.getDocument (pdf.js:2867)
at PdfViewerComponent.webpackJsonp.../../../../ng2-pdf-viewer/dist/pdf-viewer.component.js.PdfViewerComponent.loadPDF
I've searched high and low for a solution to the problem, but I just can't figure it out. Any help will be deeply appreciated.
If you want me to provide any additional information, please let me know.