I am trying to use ng2-pdf-viewer in my Angular 7 project. Initially, I was having a cors issue which I solved with this advice. Now, I am experiencing the following error:
Invalid parameter object: need either .data, .range or .url
at Object.getDocument (pdf.js:7919)
at PdfViewerComponent.push.../../../node_modules/ng2-pdf-viewer/ng2-pdf-viewer.es5.js.PdfViewerComponent.loadPDF
I tried to implement the answer from this post, but had no luck. It may be correct and I am misunderstanding how to implement.
my ts:
import {Component, OnInit} from '@angular/core'
import {DomSanitizer, SafeUrl} from '@angular/platform-browser'
@Component({
selector:'app-help-dialog',
templateUrl:'./helpDialog.html',
styleUrls:['../../style/style.css']
})
export class HelpDialog implements OnInit {
pdfSource:string = 'https://url/to/my/pdf.pdf'
safeUrl:SafeUrl
constructor(private sanitizer: DomSanitizer) {
}
ngOnInit() {
this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.pdfSource)
}
}
and my template:
<pdf-viewer [src]='safeUrl'>
</pdf-viewer>