From d5ff86b681501e8c88897331f067c7d78a0182a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Andr=C3=A9s=20Monge?= Date: Mon, 28 Aug 2023 13:50:03 -0500 Subject: [PATCH 1/2] [Fix] Properly display pdfs with page rotation --- packages/react-pdf-selection/src/components/PdfViewer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-pdf-selection/src/components/PdfViewer.tsx b/packages/react-pdf-selection/src/components/PdfViewer.tsx index c05fddf..d2a9cc6 100644 --- a/packages/react-pdf-selection/src/components/PdfViewer.tsx +++ b/packages/react-pdf-selection/src/components/PdfViewer.tsx @@ -161,7 +161,7 @@ export class PdfViewer extends Component, 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 = Math.abs(page.rotate) === 90 || Math.abs(page.rotate) === 270 ? PDFOrientation.LANDSCAPE : PDFOrientation.PORTRAIT; originalPageDimensions.set(page.pageNumber, { width, height, orientation }); } From 22d8b7307fb3acf1aa13a13b23b450214101b8f1 Mon Sep 17 00:00:00 2001 From: Daniel Chiang Guerrero Date: Thu, 31 Aug 2023 15:05:36 -0500 Subject: [PATCH 2/2] bump version --- .gitignore | 3 ++- README.md | 14 ++++++++------ packages/react-pdf-selection/package-lock.json | 2 +- packages/react-pdf-selection/package.json | 12 ++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index d7ab5eb..d51f686 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist/ node_modules/ **/*/.eslintcache -**/*/react-app-env.d.ts \ No newline at end of file +**/*/react-app-env.d.ts +.npmrc \ No newline at end of file diff --git a/README.md b/README.md index 60794bd..db499b0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +This is an adoption of work originally made by [Mathias Meuleman](https://github.com/MathiasMeuleman/react-pdf-selection) as the project apparently is no longer being maintained. + # React PDF Selection This library provides text and rectangular area selections for PDF documents. It is built on top of PDF.js by Mozilla. @@ -7,9 +9,9 @@ storage. PDF pages are virtualized to prevent too many page renders and make ren Installation is simply done with `npm` or `yarn`: ``` -npm install react-pdf-selection -// or -yarn install react-pdf-selection +npm install @nextgen-ec/react-pdf-selection +// or +yarn install @nextgen-ec/react-pdf-selection ``` After this, the `PdfViewer` component can be used to create a PDF viewer on which selections can be made. @@ -70,7 +72,7 @@ Property | Type | Required | Notes boundingRect | `BoundingRect` | yes | The bounding rectangle of the entire selection. rects | `BoundingRect[]` | yes | The bounding rectangle of each of the selections rectangles. In case of an area selection, this is equal to `boundingRect`, in case of a text selection there is one `BoundingRect` for each line of selected text. pageNumber | number | yes | 1-based page number on which the selection is made. -pageOffset | number | yes | The total offset in height, caused by all the `pageNumber - 1` pages before this one. +pageOffset | number | yes | The total offset in height, caused by all the `pageNumber - 1` pages before this one. #### `NormalizedPosition` @@ -79,7 +81,7 @@ Property | Type | Required | Notes absolute | `{boundingRect: BoundingRect; rects: BoundingRect[]}` | yes | The absolute bounding rectangles of the selection, with coordinates corresponding to the current page dimensions. The `rects` are the individual bounding rectangles for each line of text (if text selection), the `boundingRect` is the larger encompassing bounding rectangle. normalized | `{boundingRect: BoundingRect; rects: BoundingRect[]}` | yes | The normalized bounding rectangles of the selection, with coordinates normalized to the current page dimensions. The `rects` are the individual bounding rectangles for each line of text (if text selection), the `boundingRect` is the larger encompassing bounding rectangle. pageNumber | number | yes | 1-based page number on which the selection is made. -pageOffset | number | yes | The total offset in height, caused by all the `pageNumber - 1` pages before this one. +pageOffset | number | yes | The total offset in height, caused by all the `pageNumber - 1` pages before this one. #### `BoundingRect` @@ -110,7 +112,7 @@ pageYOffsets | `number[]` | An array of page height offsets, indicating at what - `pageNumber`: `number` - `boundingRect`: `BoundingRectWithCSSProperties` - `rects`: `BoundingRectWithCSSProperties[]` - + #### Shared components ##### AreaSelectionComponent Can be provided to override the default `AreaSelection` component. Should be a React class component or function component diff --git a/packages/react-pdf-selection/package-lock.json b/packages/react-pdf-selection/package-lock.json index 6c47f15..6fc634e 100644 --- a/packages/react-pdf-selection/package-lock.json +++ b/packages/react-pdf-selection/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-pdf-selection", - "version": "0.6.20", + "version": "0.6.21", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/react-pdf-selection/package.json b/packages/react-pdf-selection/package.json index 40f84b5..d3ea9dc 100644 --- a/packages/react-pdf-selection/package.json +++ b/packages/react-pdf-selection/package.json @@ -1,6 +1,6 @@ { - "name": "react-pdf-selection", - "version": "0.6.20", + "name": "@nextgen-ec/react-pdf-selection", + "version": "0.6.21", "description": "Library of React components needed for text and area selections in PDF documents.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -34,7 +34,7 @@ "replace-in-file": "^6.1.0", "typescript": "^4.1.3" }, - "author": "Mathias Meuleman ", + "author": "NextGen-EC ", "license": "MIT", "keywords": [ "pdf", @@ -46,10 +46,10 @@ ], "repository": { "type": "git", - "url": "git+https://github.com/MathiasMeuleman/react-pdf-selection.git" + "url": "git+https://github.com/NextGen-ec/react-pdf-selection.git" }, "bugs": { - "url": "https://github.com/MathiasMeuleman/react-pdf-selection/issues" + "url": "https://github.com/NextGen-ec/react-pdf-selection/issues" }, - "homepage": "https://github.com/MathiasMeuleman/react-pdf-selection#readme" + "homepage": "https://github.com/NextGen-ec/react-pdf-selection#readme" }