Ng2-pdf-viewer: How to scroll to page?

Created on 3 Mar 2017  Â·  11Comments  Â·  Source: VadimDez/ng2-pdf-viewer

version: ^1.0.2

<pdf-viewer [src]="assets/test.pdf"
            [page]="'3'"
            [original-size]="true"
            [show-all]="true"
            style="display: block;">
</pdf-viewer>

This code doesn't work. How i can scroll to 3 page in pdf file ?

enhancement

Most helpful comment

Now you can scroll to a page with the following code, add this to your component that uses pdf-viewer component

// define view child
@ViewChild(PdfViewerComponent) private pdfComponent: PdfViewerComponent;

// ...

scrollToPage(page: number) {
  this.pdfComponent.pdfViewer.scrollPageIntoView({
    pageNumber: page
  });
}

and then use it

scrollToPage(3);

All 11 comments

The functionality will be available in 2.0.0.
For now you can use [(page)]="page" with [show-all]="true". Or you can always implement your own scrollTo with js.

For now you can use [(page)]="page" with [show-all]="true".

doesn't work

You can use [stick-to-page]="true" available since 2.0.0. Closing.

Now you can scroll to a page with the following code, add this to your component that uses pdf-viewer component

// define view child
@ViewChild(PdfViewerComponent) private pdfComponent: PdfViewerComponent;

// ...

scrollToPage(page: number) {
  this.pdfComponent.pdfViewer.scrollPageIntoView({
    pageNumber: page
  });
}

and then use it

scrollToPage(3);

How can I import PdfViewerComponent, which package?

@metanav can you try?

import { PdfViewerComponent } from 'ng2-pdf-viewer/dist/pdf-viewer.component.js';

It is not working for me if anyone has made it work can you post an example

@abbasshujah Memory leaks in this lib, don't use it for large files. See https://github.com/VadimDez/ng2-pdf-viewer/issues/220

Try to use pdfjs-dist and typings for it @types/pdf. I don't remember why we didn't use this library, but pdfjs works perfect.

I want to be able to programmatically highlight things in PDF which I cant
find in PDF.js, Do you know how to do that in PDF.js

On Wed, Jun 20, 2018 at 11:06 AM, Andrei K notifications@github.com wrote:

@abbasshujah https://github.com/abbasshujah Memory leaks in this lib,
don't use it for large files. See https://github.com/VadimDez/
ng2-pdf-viewer/issues/220 http://issue-220

Try to use pdfjs-dist and typings for it @types/pdf. I don't remember why
we didn't use this library, but pdfjs works perfect.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/VadimDez/ng2-pdf-viewer/issues/63#issuecomment-398785161,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ad2TYJ-1ROXQggi5oJNVEWLXhrHIpnmfks5t-mTggaJpZM4MSONs
.

Now you can scroll to a page with the following code, add this to your component that uses pdf-viewer component

// define view child
@ViewChild(PdfViewerComponent) private pdfComponent: PdfViewerComponent;

// ...

scrollToPage(page: number) {
  this.pdfComponent.pdfViewer.scrollPageIntoView({
    pageNumber: page
  });
}

and then use it

scrollToPage(3);

I tried this in my project, but it didn't work. Any other ideas that I can show all pages and also can use pagination to guide which page I want?

Scroll is not working for me when i used it in my project please help me in this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asadullazadeh picture asadullazadeh  Â·  4Comments

kuba007 picture kuba007  Â·  3Comments

fncamm picture fncamm  Â·  4Comments

quentinmachard-niji picture quentinmachard-niji  Â·  3Comments

roginneil picture roginneil  Â·  3Comments