Skip to content

Commit 4381220

Browse files
committed
Merge branch 'main' into feature/rotation
2 parents 873e37d + 77a9f96 commit 4381220

8 files changed

Lines changed: 19 additions & 14 deletions

File tree

example/package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"react-dom": "^18.2.0",
3636
"react-fast-pdf": "^1.0.23"
3737
},
38+
"peerDependencies": {
39+
"pdfjs-dist": "^4.x || ^5.x"
40+
},
3841
"devDependencies": {
3942
"@babel/cli": "^7.22.9",
4043
"@babel/core": "^7.22.9",

example/src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React, {useState} from 'react';
2+
import pdfWorkerSource from 'pdfjs-dist/build/pdf.worker.min.mjs';
3+
import * as pdfjs from 'pdfjs-dist';
24
import ReactFastPDF, {PDFPreviewer} from 'react-fast-pdf';
35
import type {RotationDegrees} from 'react-fast-pdf';
46
import './index.css';
57

8+
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerSource], {type: 'text/javascript'}));
9+
610
function App() {
711
const [file, setFile] = useState<string | null>(null);
812
const [rotation, setRotation] = useState<RotationDegrees>(0);

package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-fast-pdf",
3-
"version": "1.0.31",
3+
"version": "1.0.32",
44
"description": "react-fast-pdf",
55
"main": "./dist/index.js",
66
"type": "module",
@@ -35,7 +35,6 @@
3535
},
3636
"peerDependencies": {
3737
"lodash": "4.x",
38-
"pdfjs-dist": "5.4.296",
3938
"react": "18.x",
4039
"react-dom": "18.x"
4140
},

src/PDFPreviewer.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import pdfWorkerSource from 'pdfjs-dist/build/pdf.worker.min.mjs';
2-
import React, {useCallback, useLayoutEffect, useRef, useState, memo} from 'react';
3-
import type {CSSProperties, ReactNode, JSX} from 'react';
4-
import {times} from 'lodash';
1+
import React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react';
2+
import type {CSSProperties, ReactNode} from 'react';
3+
import times from 'lodash/times.js';
54
import {VariableSizeList as List} from 'react-window';
6-
import {Document, pdfjs} from 'react-pdf';
5+
import {Document} from 'react-pdf';
76
import 'react-pdf/dist/Page/AnnotationLayer.css';
87
import 'react-pdf/dist/Page/TextLayer.css';
98

@@ -34,8 +33,6 @@ type Props = {
3433

3534
type OnPasswordCallback = (password: string | null) => void;
3635

37-
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerSource], {type: 'text/javascript'}));
38-
3936
const DefaultLoadingComponent = <p>Loading...</p>;
4037
const DefaultErrorComponent = <p>Failed to load the PDF file :(</p>;
4138

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import {pdfjs} from 'react-pdf';
12
import PDFPreviewer from './PDFPreviewer.js';
23
import type {RotationDegrees} from './types.js';
34

45
const PACKAGE_NAME = 'react-fast-pdf';
56

6-
export {PDFPreviewer};
7+
export {PDFPreviewer, pdfjs};
78
export type {RotationDegrees};
89

910
export default {

src/pdf.worker.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)