Ng2-pdf-viewer: stick-to-page does not work

Created on 21 Oct 2018  路  4Comments  路  Source: VadimDez/ng2-pdf-viewer

angular7 project run npm install ng2-pdf-viewer.
Two problems

  1. when I freshening the page,console an error .
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!

Most helpful comment

The stick-to-page in Angular 7 is also not working for me.

Thanks.
M.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roginneil picture roginneil  路  3Comments

viktorhajer picture viktorhajer  路  7Comments

VadimDez picture VadimDez  路  5Comments

RahmatAliMalik5 picture RahmatAliMalik5  路  5Comments

akarai9 picture akarai9  路  7Comments