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

scale not correctly updated on pdf-viewer rotation for pdf page with 90° rotation #992

Closed
QuentinChaumont opened this issue Apr 13, 2023 · 5 comments
Milestone

Comments

@QuentinChaumont
Copy link
Contributor

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
- [ ] Feature request
- [ ] Documentation issue or request

Hi, first of all thanks for your work.

Configuration of pdf-viewer :

[original-size]="false"
[page]="pageNumber"
[render-text]="true"
[show-all]="false"
[rotation]="rotation"
[show-borders]="false"
[src]="src"
[zoom-scale]="'page-width'"

Description of the issue :

When I'am using a pdf with pages already rotated on pdf-viewer it display perfectly.
But when I apply a pdf-viewer rotation of 90° on it the width scale is not updated. So my pdf succesfully rotate but it is cropped because width scale did not update.

Resolution of the issue :

I managed to find the reason on pdf-viewer.component.ts line 323 :
const rotation = this._rotation || page.rotate;
The fix is simple :
const rotation = this._rotation + page.rotate;

Explanation of the fix :

Without fix : const rotation = this._rotation || page.rotate; :

1 - pdf page with rotation already applyed on it is loaded
2 - const rotation = 90 (from page.rotate) ✔️
3- I apply pdfViewer rotation on it
4- const rotation = 90 (from this._rotation) ❎

With fix : const rotation = this._rotation + page.rotate; :

1 - pdf page with rotation already applyed on it is loaded
2 - const rotation = 90 (from this._rotation 0 + page.rotate 90 ) ✔️
3- I apply pdfViewer rotation on it
4- const rotation = 180 (from this._rotation 90 + page.rotate 90 ) ✔️

I'm doing pull request to fix this for you.

Have a good day

@VadimDez
Copy link
Owner

@QuentinChaumont thanks for the PR! i've just tested and see no difference before and after applying your changes. Can you please make some screenshots showing the difference before vs after?

@QuentinChaumont
Copy link
Contributor Author

It's a very specific use-case appear only with pdf saved with internal rotation in some pages.

For normal pdf pages without internal rotation (page.rotation) it's work fine with 90° rotation and zoom-scale= 'page-width' the pdf resize to take all the width space :

Capture d’écran du 2023-04-14 09-14-15

When I go to the third page of my pain in the ass pdf which has an internal rotation (page.rotation = 90), you can see that the pdf does not resize to use full width :

Capture d’écran du 2023-04-14 09-14-47

After my quick fix, behaviour does not change normal pages rotation but fix the pages with internal rotation :

Capture d’écran du 2023-04-14 09-17-12

@QuentinChaumont
Copy link
Contributor Author

QuentinChaumont commented Apr 14, 2023

If you want to try by yourself i give you my pdf :

  • first and second page are normal
  • third pages has internal page rotation of 90° (it's created the problem)

last-page-rotated-anonyme.pdf

@QuentinChaumont
Copy link
Contributor Author

Thx for your time.

@VadimDez VadimDez added this to the 9.1.5 milestone Apr 16, 2023
VadimDez added a commit that referenced this issue Apr 16, 2023
fix #992 : fix rotation on pdf with included rotation
@VadimDez
Copy link
Owner

Thanks @QuentinChaumont, I could replicate the issue with your PDF, will publish 9.1.5 soon

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

2 participants