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

Multiple viewers on one page #806

Closed
Spielboerg opened this issue Jul 5, 2021 · 11 comments
Closed

Multiple viewers on one page #806

Spielboerg opened this issue Jul 5, 2021 · 11 comments
Labels

Comments

@Spielboerg
Copy link

Spielboerg commented Jul 5, 2021

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [x] Bug report -> please search issues before submitting
- [x] Feature request
- [ ] Documentation issue or request

I want to display multiple PDF files one below the other on one page. Also the PDF viewer should display all pages below each other (the black rectangle stands for the viewport):

However, since the viewer container is absolutely positioned, this does not work at the moment because the viewers are stacked on top of each other.

I changed the style from .ng2-pdf-viewer-container to position: relative which leads to this error:

Error: The `container` must be absolutely positioned.

When I remove the position: absolute rule from the viewer-container in the dev tools of the browser, the preview works exactly as expected. So I don`t understand why this restriction is there?

@Spielboerg
Copy link
Author

My current workaround:

<pdf-viewer
  class="pdf-viewer"
  [class.pdf-viewer--relative]="positionPdfViewerRelative"
  [src]="objectUrl"
  [fit-to-page]="true"
  [show-all]="true"
  (after-load-complete)="handlePdfLoaded()"
></pdf-viewer>
public positionPdfViewerRelative: boolean = false;

public handlePdfLoaded(): void {
  this.positionPdfViewerRelative = true;
}
.pdf-viewer {
  display: block;

  &--relative {
    ::ng-deep .ng2-pdf-viewer-container {
      position: relative;
    }
  }
}

@stale
Copy link

stale bot commented Sep 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 4, 2021
@Spielboerg
Copy link
Author

Bump to remove stale.

@stale stale bot removed the stale label Sep 6, 2021
@podger
Copy link

podger commented Sep 21, 2021

Same here: works fine if I remove position:absolute from F12 but gives error if change the style programmatically.

@olafvanv
Copy link

olafvanv commented Oct 5, 2021

Same issue here, don't understand why this restriction is here.
Right now I'm "solving" it by using v6.4.1

@Spielboerg
Copy link
Author

@podger have you tried my workaround to eliminate the error?
#806 (comment)

@Spielboerg
Copy link
Author

@VadimDez There are more issues caused by the position: absolute: #805, #811
Therefore, please check whether this restriction is really necessary.

@podger
Copy link

podger commented Oct 5, 2021

@podger have you tried my workaround to eliminate the error? #806 (comment)

I "solved" downgrading the package to the older version.

@stale
Copy link

stale bot commented Dec 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 4, 2021
@stale stale bot closed this as completed Jan 4, 2022
@marcelo-leite
Copy link

I'm going through the same problem. "ng2-pdf-viewer": "^9.1.5",

@mejobloggs-cw
Copy link

I'm using 10.2.2 and have similar problems also.

I just want to display pdf's as part of regular flow on the page. E.g if the pdf is 100 pages long, then it will push content below it 100 pages down.

Only way I can get it to work is with .ng2-pdf-viewer-container { position: relative; }

Luckily @Spielboerg fix works for me, so a big thanks for that 👍

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

5 participants