Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stick-to-page does not work #397

Closed
xmran opened this issue Oct 21, 2018 · 4 comments
Closed

stick-to-page does not work #397

xmran opened this issue Oct 21, 2018 · 4 comments
Milestone

Comments

@xmran
Copy link

xmran commented Oct 21, 2018

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!

@xmran xmran changed the title stick-to-page do not work stick-to-page does not work Oct 21, 2018
@ihateids
Copy link

ihateids commented Nov 5, 2018

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

Thanks.
M.

@sahrmann
Copy link

sahrmann commented Nov 27, 2018

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!

@xmran
Copy link
Author

xmran commented Nov 28, 2018

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 "<!doctype html>",stick-to-page work well.

@VadimDez VadimDez added this to the 6.0.0 milestone Oct 15, 2019
@VadimDez
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants