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

[show-all] is showing first two page only. #54

Closed
shabbir-dhangot opened this issue Feb 8, 2017 · 12 comments
Closed

[show-all] is showing first two page only. #54

shabbir-dhangot opened this issue Feb 8, 2017 · 12 comments
Assignees
Labels
Milestone

Comments

@shabbir-dhangot
Copy link

show-all is showing first two page only.

<pdf-viewer [src]="pdfSrc"
[page]="page"
[original-size]="false"
[render-text]="false"
[show-all]="true"
style="display: block;">

pdfSrc: string = "../assets/pdf/Cuelinks_SDK-Integration_Guide.pdf"
page: number = 5;

I dont know what value give in page.

@markgoho
Copy link

markgoho commented Feb 8, 2017

Same issue, show-all: true is just showing the first two pages

@VadimDez VadimDez self-assigned this Feb 9, 2017
@Tyler-V
Copy link

Tyler-V commented Feb 10, 2017

Also same issue! Works fine with [show-all]="false" and using pagination to get to each page of the document but show-all is not displaying the last page.

This is true even on your demo https://vadimdez.github.io/ng2-pdf-viewer/

@fabiodursoexin
Copy link

Same issue

@VadimDez VadimDez added the bug label Feb 13, 2017
@jahller
Copy link

jahller commented Feb 15, 2017

Same issue here.

@clgraf
Copy link

clgraf commented Feb 16, 2017

Same problem

@VadimDez VadimDez added this to the 2.0.0 milestone Feb 16, 2017
@smlee
Copy link

smlee commented Feb 16, 2017

I have the number of pages stored in my database so i use ngFor by creating an empty array based on the number of pages and index + 1 for the workaround

@Tyler-V
Copy link

Tyler-V commented Feb 17, 2017

I have the number of pages stored in my database so i use ngFor by creating an empty array based on the number of pages and index + 1 for the workaround

afterLoad() I am using the PDFDocumentProxy and calling pdf.getPage(i) in a loop to get each PDFPageProxy and calling render on each page. No need to fetch the pdf more than once.

<pdf-viewer #pdfViewer [src]="url" [page]="1" (after-load-complete)="afterLoad($event)">
</pdf-viewer>
<ng-container *ngFor="let page of remainingPdfPages; let i = index">
    <canvas class="pdf-page" [attr.page]="i + 2"></canvas>
</ng-container>
afterLoad(pdf: PDFDocumentProxy) {
    this.totalPages = pdf.numPages;
    this.remainingPdfPages = new Array(pdf.numPages - 1);
    setTimeout(() => {
        for (let i = 2; i < pdf.numPages + 1; i++) {
            pdf.getPage(i).then((page: PDFPageProxy) => {
                let scale = 1.0;
                let viewport = page.getViewport(scale);
                let canvas: any = $(".pdf-page[page='" + i + "']")[0];
                let context = canvas.getContext('2d');
                canvas.height = viewport.height;
                canvas.width = viewport.width;
                let renderContext = {
                    canvasContext: context,
                    viewport: viewport
                };
                page.render(renderContext);
            });
        }
    });
}

@JonnyNet
Copy link

pdf-viewer.component.js

`PdfViewerComponent.prototype.renderMultiplePages = function () {
var _this = this;
var container = this.element.nativeElement.querySelector('div');
var page = 1;
this.removeAllChildNodes(container);

    for(let i = 1; i < _this._pdf.numPages+1 ; i++){
        this.renderPage(i)
    }

   /* this.renderPage(page++).then(function () {
        if (page <= _this._pdf.numPages) {
            return _this.renderPage(page++);
        }
    });*/ 
};`

@VadimDez VadimDez modified the milestones: 1.0.2, 2.0.0 Feb 20, 2017
VadimDez added a commit that referenced this issue Feb 20, 2017
@philipdbrown
Copy link

philipdbrown commented Jun 21, 2021

I know this issue is closed, but I'm experiencing it in the following version:
ng2-pdf-viewer: 7.0.1
angular/cli: 11.2.4

Any help would be appreciated.

@Or05230
Copy link

Or05230 commented Jul 5, 2021

I know this issue is closed, but I'm experiencing it in the following version:
ng2-pdf-viewer: 7.0.1
angular/cli: 11.2.4

Any help would be appreciated.
pdf-viewer { height: 100vh display:block; }

make sure nothing override it.

@gabayarden
Copy link

Using ng2-pdf-viewer: 7.0.1 and it is not working here again.
Downgraded to 6.4.0 and it works.
Seems like 7.0.1 has some issue

@conner-fallone
Copy link

So this appears to be something with the scrolling / virtualization implementation. I was having this same issue, but noticed all the pages were still in the DOM, the scroll just wasn't recognized. In my scenario, i was using overflow-x: unset to get rid of the horizontal scrollbar that always appears to show (going to write up an issue for this, seems like this lib is not accounting for a vertical scrollbar and renders the page underneath it). If you are doing something special with this scrollbar, you may be interfering with this scroll. In my case, just removing this style fixed it and the scroll started rendering pages. overflow-x: hidden also works too.

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

No branches or pull requests