Skip to content

Ft/page rot metadata #7

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 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist/
node_modules/

**/*/.eslintcache
**/*/react-app-env.d.ts
**/*/react-app-env.d.ts
.npmrc
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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`

Expand All @@ -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`

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/react-pdf-selection/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/react-pdf-selection/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -34,7 +34,7 @@
"replace-in-file": "^6.1.0",
"typescript": "^4.1.3"
},
"author": "Mathias Meuleman <[email protected]>",
"author": "NextGen-EC <[email protected]>",
"license": "MIT",
"keywords": [
"pdf",
Expand All @@ -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"
}
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 = Math.abs(page.rotate) === 90 || Math.abs(page.rotate) === 270 ? PDFOrientation.LANDSCAPE : PDFOrientation.PORTRAIT;
originalPageDimensions.set(page.pageNumber, { width, height, orientation });
}

Expand Down