Skip to content

[Fix] Add support for documents with 270 degree of page rotation #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-pdf-selection/src/components/PdfViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class PdfViewer<D extends object> extends Component<PdfViewerProps<D>, Pd
for (const page of pages) {
const width = page.view[2];
const height = page.view[3];
const orientation = page.rotate === 90 ? PDFOrientation.LANDSCAPE : PDFOrientation.PORTRAIT;
const orientation = page.rotate === 270 ? PDFOrientation.LANDSCAPE : PDFOrientation.PORTRAIT;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be

Suggested change
const orientation = page.rotate === 270 ? PDFOrientation.LANDSCAPE : PDFOrientation.PORTRAIT;
const orientation = Math.abs(page.rotate) === 90 || Math.abs(page.rotate) === 270 ? PDFOrientation.LANDSCAPE : PDFOrientation.PORTRAIT;

since according to metadata2go 90 and -90 are possible valid values for landscape

originalPageDimensions.set(page.pageNumber, { width, height, orientation });
}

Expand Down