@react-pdf-kit/viewer 2.0.1-rc.0 → 2.0.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +88 -49
  2. package/dist/{Combination-54a77a7a.js → Combination-136ff99c.js} +184 -187
  3. package/dist/components/layout/RPDefaultLayout.js +2 -2
  4. package/dist/components/layout/RPLayout.js +2 -2
  5. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  6. package/dist/components/layout/toolbar/DocumentProperties.js +2 -2
  7. package/dist/components/layout/toolbar/FileDownloadTool.js +2 -2
  8. package/dist/components/layout/toolbar/FileUploadTool.js +2 -2
  9. package/dist/components/layout/toolbar/FullScreenTool.js +2 -2
  10. package/dist/components/layout/toolbar/MenuItem.js +2 -2
  11. package/dist/components/layout/toolbar/MenuSeparator.js +2 -2
  12. package/dist/components/layout/toolbar/MostPageTool.js +2 -2
  13. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  14. package/dist/components/layout/toolbar/PrintTool.js +2 -2
  15. package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
  16. package/dist/components/layout/toolbar/RPMoreOptions.js +2 -2
  17. package/dist/components/layout/toolbar/RPToolbar.js +2 -2
  18. package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -2
  19. package/dist/components/layout/toolbar/RotateTool.js +2 -2
  20. package/dist/components/layout/toolbar/ScrollModeTool.js +2 -2
  21. package/dist/components/layout/toolbar/SearchTool.js +2 -2
  22. package/dist/components/layout/toolbar/SelectionModeTool.js +2 -2
  23. package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
  24. package/dist/components/layout/toolbar/ToolbarLayout.js +2 -2
  25. package/dist/components/layout/toolbar/ViewModeTool.js +2 -2
  26. package/dist/components/layout/toolbar/ZoomTool.js +2 -2
  27. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
  28. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +2 -2
  29. package/dist/components/layout/toolbar/tools/FirstPageTool.js +2 -2
  30. package/dist/components/layout/toolbar/tools/LastPageTool.js +2 -2
  31. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
  32. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +2 -2
  33. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  34. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
  35. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
  36. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  37. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +2 -2
  38. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
  39. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
  40. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +2 -2
  41. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
  42. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
  43. package/dist/components/ui/DropDown.js +2 -2
  44. package/dist/{index-4baea9b5.js → index-61f59539.js} +1 -1
  45. package/dist/main.js +2 -2
  46. package/dist/utils/highlight.js +36 -36
  47. package/dist/utils/hooks/useHighlight.js +78 -40
  48. package/dist/utils/hooks/useLicense.js +1 -1
  49. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <a href="https://www.react-pdf.dev/" target="_blank">
2
+ <a href="https://www.react-pdf-kit.dev/" target="_blank">
3
3
  <picture>
4
4
  <source srcset="https://raw.githubusercontent.com/pdf-viewer-react/react-pdf/2308e7d88cde64bf343f1509150ebf6c91a15664/assets/img/react-pdf_cover.webp" width="100%">
5
5
  <img alt="React PDF" src="https://raw.githubusercontent.com/pdf-viewer-react/react-pdf/2308e7d88cde64bf343f1509150ebf6c91a15664/assets/img/react-pdf_cover.webp" width="100%">
@@ -9,28 +9,32 @@
9
9
 
10
10
  <br/>
11
11
  <div align="center">
12
- Works seamlessly on your React.js websites. Fast, Customizable and Web Responsive PDF viewer. Save you weeks of development time.
12
+ Works seamlessly on your React or Next.js websites. Fast, Customizable and Web Responsive PDF viewer. Save you weeks of development time.
13
13
  </div>
14
14
  <br/>
15
15
 
16
16
  <div align="center">
17
17
 
18
- [React PDF Home][reactpdf] - [License](#page_facing_up-license) - [Documentation][reactpdf-docs]
18
+ [React PDF Kit Home][reactpdf] - [License](#page_facing_up-license) - [Documentation][reactpdf-docs]
19
19
 
20
- [![NPM Version](https://img.shields.io/npm/v/%40pdf-viewer%2Freact)][npm]
20
+ [![NPM Version](https://img.shields.io/npm/v/%40react-pdf-kit%2Fviewer)][npm]
21
21
  [![Twitter](https://img.shields.io/twitter/follow/ReactPDF?label=ReactPDF&style=social)][twitter]
22
22
 
23
23
  </div>
24
24
 
25
- # :star: Why React PDF
25
+ # :star: Why React PDF Kit
26
26
 
27
- - **Save Weeks of Development Time**: React PDF simplifies PDF integration with ready-to-use tools, minimizing the need for custom development and saving you valuable time.
27
+ - **Save Weeks of Development Time**: React PDF Kit simplifies PDF integration with ready-to-use tools, minimizing the need for custom development and saving you valuable time.
28
28
  - **Tailored for React.js**: React PDF is native to React.js, ensuring smooth integration into your projects.
29
29
  - **Customizability at Its Core**: Built with flexibility in mind, allowing you to match your application’s unique style and functionality.
30
30
  - **High-Performance & Rapid Rendering**: Optimized for rendering large PDFs efficiently, React PDF delivers lightning-fast load times with features like virtual scrolling.
31
- - **Accessibility**: Designed with inclusivity in mind, React PDF supports ARIA attributes, catering to diverse user bases.
32
- - **Modern Browser Compatibility**: Works seamlessly across modern browsers, eliminating compatibility headaches.
33
- - **Active Development & Support**: With regular updates and a responsive support team, React PDF evolves to meet developer needs.
31
+ - **Accessibility**: Designed with inclusivity in mind, React PDF Kit supports ARIA attributes, catering to diverse user bases.
32
+ - **Modern Browser Compatibility**: The React PDF Viewer components seamlessly across modern browsers, eliminating compatibility headaches.
33
+ - **Active Development & Support**: With regular updates and a responsive support team, React PDF Kit evolves to meet developer needs.
34
+
35
+ # 📜 Background
36
+
37
+ As developers ourselves, we faced many issues such as browser incompatibility and customizability while trying to render a PDF document or working with PDF libraries. Having faced issues using PDF libraries, we want the solution to be flexible for React.js developers and teams. More importantly, the technical document must be easy to use!
34
38
 
35
39
  # 📜 Background
36
40
 
@@ -47,35 +51,58 @@ As developers ourselves, we faced many issues such as browser incompatibility an
47
51
  - 📂 **Document Management Tools**, including features like downloading and printing.
48
52
  - 👁️ **Accessibility Support** to built-in support for ARIA attributes and tooltips, catering to diverse user bases.
49
53
 
50
- For the full feature set, visit [React PDF Features](https://www.react-pdf.dev/features?utm_source=github).
54
+ For the full feature set, visit [React PDF Kit Features](https://www.react-pdf-kit.dev/features?utm_source=github&utm_medium=referral).
51
55
 
52
56
  # :zap: Quick Start Guide
53
57
 
54
- Here’s how to get started with React PDF in your React.js project:
58
+ Here’s how to get started with React PDF Kit in your React.js project:
55
59
 
56
- ## 1. Check Prerequisites
60
+ ## 1. Check Prerequsities
57
61
 
58
- Here are the basic system requirements to run the React PDF component:
62
+ Here are the basic system requirements to run the React PDF Viewer component:
59
63
 
60
64
  - React version: >= 18.0
65
+ - React version: >= 19.0
61
66
 
62
- If you are working with a React framework such as Next and Gatsby, React PDF can run smoothly as long as you are using React 18 and above.
67
+ If you are working with a React framework such as Next.js (App Router and Pages Router) or Gatsby, React PDF can run smoothly as long as you are using React 18 and above.
63
68
 
64
- React PDF viewer also works well with other React.js UI libraries such as MUI, Ant Design and Chakra UI.
69
+ React PDF also works well with other React.js UI libraries such as MUI, Ant Design and Chakra UI.
65
70
 
66
- Although React PDF can run on most JavaScript module bundlers, it is more vigorously tested on Vite and Webpack.
71
+ Although React PDF Kit can run on most JavaScript module bundlers, it is more vigorously tested on Vite and Webpack.
67
72
 
68
73
  _Remark: <br/>- If using TypeScript, it requires >= TypeScript 4.6._
69
74
 
70
75
  ### Browser support
71
76
 
77
+ Starting from [`@react-pdf-kit/viewer@^2.0.0`](https://www.npmjs.com/package/@react-pdf-kit/viewer), we officially support PDF.js 5 and default to PDF.js `5.4.530`.
78
+
79
+ As newer PDF.js versions rely on more modern browser APIs, minimum supported browser versions have changed. Please review the compatibility details below before choosing a PDF.js version.
80
+
81
+ #### Default (PDF.js 5.4.530)
82
+
83
+ React PDF Kit v2.0.0 defaults to PDF.js `5.4.530`.
84
+
72
85
  | Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
73
86
  | ------ | ------- | ---- | ------ | ---------- | -------------- |
74
- | 115+ | 115+ | 115+ | 16.5+ | 16.5+ | 126+ |
87
+ | 126+ | 126+ | 126+ | 18.4+ | 18.4+ | 126+ |
88
+
89
+ <Aside>
90
+ It's currently not recommended to use a PDF.js worker version beyond `5.4.530` because it will support fewer browser versions.
91
+ </Aside>
92
+
93
+ #### Using PDF.js 4.10.38
94
+
95
+ If you need broader browser compatibility, you can continue using PDF.js `4.10.38`, which supports:
96
+
97
+ | Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
98
+ | ------ | ------- | ---- | ------ | ---------- | -------------- |
99
+ | 119+ | 115+ | 115+ | 17.4+ | 17.4+ | 126+ |
100
+
101
+ To change the version of PDF.js used, refer to [Dependency Override](https://docs.react-pdf-kit.dev/usage-guide/overriding-dependency?utm_source=github&utm_medium=referral) guide.
75
102
 
76
103
  ## 2. Install the Package
77
104
 
78
- There are a few ways you can install React PDF, namely `bun`, `npm`, `pnpm` or `yarn`.
105
+ There are a few ways you can install React PDF Kit, namely `bun`, `npm`, `pnpm` or `yarn`.
79
106
 
80
107
  ### Using bun:
81
108
 
@@ -110,50 +137,42 @@ yarn add @react-pdf-kit/viewer
110
137
  pnpm add @react-pdf-kit/viewer
111
138
  ```
112
139
 
113
- For more information on how to use different package managers, please visit our [installation guide](https://docs.react-pdf.dev/introduction/getting-started.html#installation?utm_source=github).
140
+ For more information on how to use different package managers, please visit our [installation guide](https://docs.react-pdf-kit.dev/introduction/getting-started/#installation?utm_source=github&utm_medium=referral).
114
141
 
115
142
  ## 3. Import and Use the Component
116
143
 
117
144
  The following structure demonstrates how to build a React PDF viewer by importing and assembling components. This modular approach gives you the flexibility to customize the viewer as needed.
118
145
 
119
146
  ```tsx
120
- <RPConfig>
121
- {' '}
122
- {/* Configuration license and pdfjs-dist worker */}
123
- <RPProvider>
124
- {' '}
125
- {/* Viewer context provider */}
126
- <RPTheme>
127
- {' '}
128
- {/* Theme customization (optional) */}
129
- <RPDefaultLayout>
130
- {' '}
131
- {/* Default layout container */}
132
- <RPPages /> {/* PDF pages renderer */}
133
- </RPDefaultLayout>
134
- </RPTheme>
135
- </RPProvider>
147
+ <RPConfig> {/* Configuration license and pdfjs-dist worker */}
148
+ <RPTheme> {/* Theme customization (optional) */}
149
+ <RPProvider> {/* Viewer context provider */}
150
+ <RPLayout toolbar> {/* Provide the default toolbar structure */}
151
+ <RPPages /> {/* Render the actual PDF content */}
152
+ </RPLayout>
153
+ </RPProvider>
154
+ </RPTheme>
136
155
  </RPConfig>
137
156
  ```
138
157
 
139
- _Remark: For more information on each component, please refer to [Component](https://docs.react-pdf.dev/components/overview?utm_source=github)._
158
+ _Remark: For more information on each component, please refer to [Component](https://docs.react-pdf-kit.dev/components/overview?utm_source=github&utm_medium=referral)._
140
159
 
141
160
  ### Basic Usage
142
161
 
143
- The most basic usage of React PDF viewer needs four components, namely: `RPConfig`, `RPProvider`, `RPDefaultLayout`, and `RPPages`.
162
+ The most basic usage of React PDF viewer needs four components, namely: `RPConfig`, `RPProvider`, `RPLayout`, and `RPPages`.
144
163
 
145
164
  Here's how to implement a basic PDF viewer in a React application:
146
165
 
147
166
  ```jsx
148
- import { RPProvider, RPDefaultLayout, RPPages, RPConfig } from '@react-pdf-kit/viewer'
167
+ import { RPProvider, RPLayout, RPPages, RPConfig } from '@react-pdf-kit/viewer'
149
168
 
150
169
  const App = () => {
151
170
  return (
152
171
  <RPConfig>
153
172
  <RPProvider src="https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf">
154
- <RPDefaultLayout style={{ height: '660px' }}>
173
+ <RPLayout toolbar style={{ height: '660px' }}>
155
174
  <RPPages />
156
- </RPDefaultLayout>
175
+ </RPLayout>
157
176
  </RPProvider>
158
177
  </RPConfig>
159
178
  )
@@ -161,13 +180,13 @@ const App = () => {
161
180
  export default App
162
181
  ```
163
182
 
164
- The PDF viewer will automatically adjust to fit its container's dimensions. You can control the size by setting the `style` prop on `RPDefaultLayout`. For more information on using React PDF, visit our [basic usage guide](https://docs.react-pdf.dev/introduction/basic-usage?utm_source=github)
183
+ The PDF viewer will automatically adjust to fit its container's dimensions. You can control the size by setting the `style` prop on `RPLayout`. For more information on using React PDF, visit our [basic usage guide](https://docs.react-pdf-kit.dev/introduction/basic-usage?utm_source=github&utm_medium=referral)
165
184
 
166
185
  You may also check out our [Starter Toolkit](#pushpin-starter-toolkit) for examples to get you started.
167
186
 
168
187
  ### 4. Customize with Hooks and Props
169
188
 
170
- To enhance React PDF further, we offer built-in hooks and props that let you fine-tune functionality, adjust appearance, and integrate custom behaviors into your application.
189
+ To enhance React PDF Kit further, we offer built-in hooks and props that let you fine-tune functionality, adjust appearance, and integrate custom behaviors into your application.
171
190
 
172
191
  For detailed usage, refer to our [Documentation][reactpdf-docs].
173
192
 
@@ -176,11 +195,31 @@ For detailed usage, refer to our [Documentation][reactpdf-docs].
176
195
  Here are some sample projects to get started on React PDF quickly:
177
196
 
178
197
  1. [React (webpack) - JavaScript](https://github.com/react-pdf-kit/starter-rp-react-js-webpack)
179
- 2. [React (webpack) - TypeScript](https://github.com/reactpdf/pdf-viewer-react/starter-rp-react-ts-webpack)
198
+ 2. [React (webpack) - TypeScript](https://github.com/react-pdf-kit/starter-rp-react-ts-webpack)
180
199
  3. [React (vite) - JavaScript](https://github.com/react-pdf-kit/starter-rp-react-js-vite)
181
200
  4. [React (vite) - TypeScript](https://github.com/react-pdf-kit/starter-rp-react-ts-vite)
182
- 5. [Next - JavaScript](https://github.com/react-pdf-kit/starter-rp-next-js)
183
- 6. [Next - TypeScript](https://github.com/react-pdf-kit/starter-rp-next-ts)
201
+ 5. [React (vite) - TypeScript - Turborepo](https://github.com/react-pdf-kit/starter-rp-react-vite-ts-turborepo)
202
+ 6. [Next.js - JavaScript (App Router)](https://github.com/react-pdf-kit/starter-rp-nextjs-app-router-js)
203
+ 7. [Next.js - TypeScript (App Router)](https://github.com/react-pdf-kit/starter-rp-nextjs-app-router-ts)
204
+ 8. [Next.js - JavaScript (Pages Router)](https://github.com/react-pdf-kit/starter-rp-nextjs-pages-router-js)
205
+ 9. [Next.js - TypeScript (Pages Router)](https://github.com/react-pdf-kit/starter-rp-nextjs-pages-router-ts)
206
+ 10. [Next.js - TypeScript - Turborepo](https://github.com/react-pdf-kit/starter-rp-next-ts-turborepo)
207
+ 11. [Remix - JavaScript](https://github.com/react-pdf-kit/starter-rp-remix-js)
208
+ 12. [Remix - TypeScript](https://github.com/react-pdf-kit/starter-rp-remix-ts)
209
+ 13. [Gatsby - JavaScript](https://github.com/react-pdf-kit/starter-rp-gatsby-js)
210
+ 14. [Gatsby - TypeScript](https://github.com/react-pdf-kit/starter-rp-gatsby-ts)
211
+ 15. [Docusaurus - JavaScript](https://github.com/react-pdf-kit/starter-rp-docusaurus-js)
212
+ 16. [Docusaurus - TypeScript](https://github.com/react-pdf-kit/starter-rp-docusaurus-ts)
213
+ 17. [Electron - JavaScript](https://github.com/react-pdf-kit/starter-rp-electron-js-vite)
214
+ 18. [Electron - TypeScript](https://github.com/react-pdf-kit/starter-rp-electron-ts-vite)
215
+ 19. [React Router - JavaScript](https://github.com/react-pdf-kit/starter-rp-react-router-js)
216
+ 20. [React Router - TypeScript](https://github.com/react-pdf-kit/starter-rp-react-router-ts)
217
+ 21. [TanStack - JavaScript](https://github.com/react-pdf-kit/starter-rp-tanstack-router-js)
218
+ 22. [TanStack - TypeScript](https://github.com/react-pdf-kit/starter-rp-tanstack-router-ts)
219
+
220
+ # 📝 Changelog
221
+
222
+ Check out our latest release [v2.0.0 (20 February 2026)](https://docs.react-pdf-kit.dev/introduction/changelog/#v200-20-february-2026?utm_source=github&utm_medium=referral)
184
223
 
185
224
  # :raising_hand: Need Help?
186
225
 
@@ -188,9 +227,9 @@ We are more than happy to help you. If you have any questions, run into any erro
188
227
 
189
228
  # :page_facing_up: License
190
229
 
191
- React PDF is distributed under our proprietary license. Please refer to our [License page](https://www.react-pdf.dev/license-agreement?utm_source=github) file for more details.
230
+ React PDF Kit is distributed under our proprietary license. Please refer to our [License page](https://www.react-pdf-kit.dev/license-agreement?utm_source=github&utm_medium=referral) file for more details.
192
231
 
193
- If you would like to use React PDF commercially, please purchase a license from [our website][reactpdf] or reach out to us directly at [david@react-pdf.dev](mailto:david@react-pdf.dev).
232
+ If you would like to use React PDF commercially, please purchase a license from [our website][reactpdf] or reach out to us directly at [https://www.react-pdf-kit.dev/contact-us](https://www.react-pdf-kit.dev/contact-us?utm_source=github&utm_medium=referral).
194
233
 
195
234
  # Acknowledgement
196
235
 
@@ -198,7 +237,7 @@ If you would like to use React PDF commercially, please purchase a license from
198
237
  - [Img Shields](https://shields.io)
199
238
  - [React.js](https://reactjs.org/)
200
239
 
201
- [reactpdf]: https://www.react-pdf.dev
202
- [reactpdf-docs]: https://docs.react-pdf.dev
240
+ [reactpdf]: https://www.react-pdf-kit.dev/?utm_source=github&utm_medium=referral
241
+ [reactpdf-docs]: https://docs.react-pdf-kit.dev/?utm_source=github&utm_medium=referral
203
242
  [npm]: https://www.npmjs.com/package/@react-pdf-kit/viewer
204
243
  [twitter]: https://www.x.com/ReactPDF