angular7 project run npm install ng2-pdf-viewer.
Two problems
core.js:12301 ERROR TypeError: Cannot read property 'div' of undefined
at PDFViewer._resetCurrentPageView (pdf_viewer.js:4881)
at PDFViewer._setCurrentPageNumber (pdf_viewer.js:4595)
at PDFViewer.set (pdf_viewer.js:5217)
at ng2-pdf-viewer.es5.js:617
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:13842)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask (zone.js:496)
at ZoneTask.invoke (zone.js:485)
2.stick-to-page do not work
html:
<button (click)="getPage()">璺宠浆</button>
<pdf-viewer [src]="pdfSrc"
[(page)]="page"
[show-all]="showAll"
[stick-to-page]="stickToPage"
></pdf-viewer>
ts:
import { Component,ViewChild } from '@angular/core';
import {PDFSource, PDFDocumentProxy} from "pdfjs-dist";
import {PdfViewerComponent} from "ng2-pdf-viewer";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'my-app';
page = 1;
showAll = true;
stickToPage = true;
pdfSrc: string | PDFSource | ArrayBuffer = './assets/pdf-test.pdf';
getPage(){
this.page = 3;
}
}
module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {PdfViewerModule} from "ng2-pdf-viewer";
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
PdfViewerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
There are my two problems,I hope I can get you help,thank you very much!
The stick-to-page in Angular 7 is also not working for me.
Thanks.
M.
Same problem here. Jumping to the search results does not work either. I hope there will be a solution for it. Many thanks in advance!
Same problem here. Jumping to the search results does not work either. I hope there will be a solution for it. Many thanks in advance!
In index.html.remove "",stick-to-page work well.
Fixed in 6.0.0 See https://github.com/VadimDez/ng2-pdf-viewer/blob/master/CHANGELOG.md#600
Most helpful comment
The stick-to-page in Angular 7 is also not working for me.
Thanks.
M.