Skip to content

Commit 23172c5

Browse files
Initial commit
0 parents  commit 23172c5

File tree

3 files changed

+196
-0
lines changed

3 files changed

+196
-0
lines changed

README.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<div align="center">
2+
<a href="https://www.react-pdf.dev/" target="_blank">
3+
<picture>
4+
<source srcset="./assets/img/react-pdf_cover.webp" width="100%">
5+
<img alt="React PDF" src="./assets/img/react-pdf_cover.webp width="100%">
6+
</picture>
7+
</a>
8+
</div>
9+
10+
<br/>
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.
13+
</div>
14+
<br/>
15+
16+
<div align="center">
17+
18+
[React PDF Home][reactpdf] - [License](#page_facing_up-license) - [Documentation][reactpdf-docs]
19+
20+
[![NPM Version](https://img.shields.io/npm/v/%40pdf-viewer%2Freact)][npm]
21+
[![Twitter](https://img.shields.io/twitter/follow/ReactPDF?label=ReactPDF&style=social)][twitter]
22+
23+
</div>
24+
25+
# :star: Why React PDF
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.
28+
- **Tailored for React.js**: React PDF is native to React.js, ensuring smooth integration into your projects.
29+
- **Customizability at Its Core**: Built with flexibility in mind, allowing you to match your application’s unique style and functionality.
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.
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!
38+
39+
# :sparkles: Features
40+
41+
- 🎯 **Interactive & Immersive Viewing Experience** with features like rotation, zoom, and keyboard navigation.
42+
- 📱 **Responsive Across All Devices** for a consistent experience on desktops, tablets and mobile devices.
43+
- 🎨 **Customizable UI and Styling** to tailor the viewer’s appearance to match your website’s theme.
44+
- 🧭 **Advanced Navigation Options** to browse documents easily with table of contents, hyperlinks, and a powerful search tool.
45+
-**High-Performance Rendering** to load large PDF documents quickly and handle complex elements like vector graphics with ease.
46+
- 🔧 **Programmatic Control with Hooks and Props**, allowing you to interact with the viewer programmatically.
47+
- 📂 **Document Management Tools**, including features like downloading and printing.
48+
- 👁️ **Accessibility Support** to built-in support for ARIA attributes and tooltips, catering to diverse user bases.
49+
50+
For the full feature set, visit [React PDF Features](https://www.react-pdf.dev/features?utm_source=github).
51+
52+
# :zap: Quick Start Guide
53+
54+
Here’s how to get started with React PDF in your React.js project:
55+
56+
## 1. Check Prerequsities
57+
58+
Here are the basic system requirements to run the React PDF component:
59+
60+
- React version: >= 18.0
61+
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.
63+
64+
React PDF viewer also works well with other React.js UI libraries such as MUI, Ant Design and Chakra UI.
65+
66+
Although React PDF can run on most JavaScript module bundlers, it is more vigorously tested on Vite and Webpack.
67+
68+
_Remark: <br/>- If using TypeScript, it requires >= TypeScript 4.6._
69+
70+
### Browser support
71+
72+
| Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
73+
| ------ | ------- | ---- | ------ | ---------- | -------------- |
74+
| 115+ | 115+ | 115+ | 16.5+ | 16.5+ | 126+ |
75+
76+
## 2. Install the Package
77+
78+
There are a few ways you can install React PDF, namely `bun`, `npm`, `pnpm` or `yarn`.
79+
80+
### Using bun:
81+
82+
```bash
83+
bun add @pdf-viewer/react
84+
```
85+
86+
##### Caching of previous Worker version with `bun`
87+
88+
To clear cache, try running `bun pm cache rm` to remove cache in the global cache directory. If the error remains, try executing the following steps:
89+
90+
```shell
91+
rm bun.lockb
92+
rm -R node_modules
93+
```
94+
95+
### Using npm:
96+
97+
```bash
98+
npm install @pdf-viewer/react
99+
```
100+
101+
### Using yarn:
102+
103+
```bash
104+
yarn add @pdf-viewer/react
105+
```
106+
107+
### Using pnpm:
108+
109+
```bash
110+
pnpm add @pdf-viewer/react
111+
```
112+
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).
114+
115+
## 3. Import and Use the Component
116+
117+
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+
119+
```tsx
120+
<RPConfig> {/* Configuration license and pdfjs-dist worker */}
121+
<RPProvider> {/* Viewer context provider */}
122+
<RPTheme> {/* Theme customization (optional) */}
123+
<RPDefaultLayout> {/* Default layout container */}
124+
<RPPages /> {/* PDF pages renderer */}
125+
</RPDefaultLayout>
126+
</RPTheme>
127+
</RPProvider>
128+
</RPConfig>
129+
```
130+
131+
_Remark: For more information on each component, please refer to [Component](https://docs.react-pdf.dev/components/overview?utm_source=github)._
132+
133+
### Basic Usage
134+
135+
The most basic usage of React PDF viewer needs four components, namely: `RPConfig`, `RPProvider`, `RPDefaultLayout`, and `RPPages`.
136+
137+
Here's how to implement a basic PDF viewer in a React application:
138+
139+
```jsx
140+
import { RPProvider, RPDefaultLayout, RPPages, RPConfig } from '@pdf-viewer/react'
141+
142+
const App = () => {
143+
return (
144+
<RPConfig>
145+
<RPProvider src="https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf">
146+
<RPDefaultLayout style={{ height: '660px' }}>
147+
<RPPages />
148+
</RPDefaultLayout>
149+
</RPProvider>
150+
</RPConfig>
151+
)
152+
}
153+
export default App
154+
```
155+
156+
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)
157+
158+
You may also check out our [Starter Toolkit](#pushpin-starter-toolkit) for examples to get you started.
159+
160+
### 4. Customize with Hooks and Props
161+
162+
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.
163+
164+
For detailed usage, refer to our [Documentation][reactpdf-docs].
165+
166+
# :pushpin: Starter Toolkit
167+
168+
Here are some sample projects to get started on React PDF quickly:
169+
170+
1. [React (webpack) - JavaScript](https://github.com/pdf-viewer-react/starter-rp-react-js-webpack)
171+
2. [React (webpack) - TypeScript](https://github.com/reactpdf/pdf-viewer-react/starter-rp-react-ts-webpack)
172+
3. [React (vite) - JavaScript](https://github.com/pdf-viewer-react/starter-rp-react-js-vite)
173+
4. [React (vite) - TypeScript](https://github.com/pdf-viewer-react/starter-rp-react-ts-vite)
174+
6. [Next - JavaScript](https://github.com/pdf-viewer-react/starter-rp-next-js)
175+
7. [Next - TypeScript](https://github.com/pdf-viewer-react/starter-rp-next-ts)
176+
177+
# :raising_hand: Need Help?
178+
179+
We are more than happy to help you. If you have any questions, run into any errors or face any problems, please feel free to create an issue in [Issues](../../issues) or PM us directly in [Twitter][twitter]. Anything related to React PDF is on the table!
180+
181+
# :page_facing_up: License
182+
183+
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.
184+
185+
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).
186+
187+
# Acknowledgement
188+
189+
- [pdf.js](https://github.com/mozilla/pdf.js)
190+
- [Img Shields](https://shields.io)
191+
- [React.js](https://reactjs.org/)
192+
193+
[reactpdf]: https://www.react-pdf.dev
194+
[reactpdf-docs]: https://docs.react-pdf.dev
195+
[npm]: https://www.npmjs.com/package/@pdf-viewer/react
196+
[twitter]: https://www.x.com/ReactPDF

assets/img/react-pdf_cover.webp

19.3 KB
Loading
49.4 KB
Loading

0 commit comments

Comments
 (0)