3

I am currently working with ngx-extended-pdf-viewer with Angular8+ to render a PDF, it doesn't work. And I keep getting the runtime error "Can't bind to 'src' since it isn't a known property of 'pdf-viewer'".

Does anyone know why this is?

Here is my HTML:

            <div class="row">
                <div class="col-md-12">
                    <div class="card-body">
                        <ngx-extended-pdf-viewer 
                            [src]="pdfSrc" 
                            [useBrowserLocale]="true" 
                            [textLayer]="true"
                            [showHandToolButton]="true"
                            [height]="'100vh'">
                        </ngx-extended-pdf-viewer>

                    </div>
                </div>
            </div>

my app.module.ts

...
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';

@NgModule({
  imports: [
    NgxExtendedPdfViewerModule,
    ....

  ],
  declarations: [
    AppComponent,
    ...


  ],
  providers: [
   ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Here is my .ts

import { Component, OnInit } from '@angular/core';
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';


    @Component({
      selector: 'app-video-reader',
      templateUrl: './video-reader.component.html',
      styleUrls: ['./video-reader.component.css'],
      providers: [NgxExtendedPdfViewerModule]

    })
    export class VideoReaderComponent implements OnInit {

      pdfSrc = "assets/example.pdf";  /* PDF*/


      constructor() { }

      ...

      ngOnInit(): void {
        this.video = 'jYvkMv7LzCw';
        this.init();
      }

     ...

    }

my app.component.ts

import { Component} from '@angular/core';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

}
Stephan Rauh
  • 3,069
  • 2
  • 18
  • 37
tesnim
  • 133
  • 1
  • 2
  • 8

3 Answers3

1

I solved my problem by:

> npm update 
> npm install
> npm audit fix --force
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
tesnim
  • 133
  • 1
  • 2
  • 8
0

Try [(src)]="pdfSrc"

It's a two-way binding attribute.

Jiharz
  • 9
  • 1
-1

Use src="pdfSrc"

It's works

vishal
  • 1
  • 1
  • 1
    Welcome to StackOverflow and thanks for your contribution! Unfortunately, the OP is asking for "binding" and this will not achieve that. Please consider modifying this answer. – Ryan Naccarato Feb 17 '23 at 22:07
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 23 '23 at 17:01