An open API service indexing awesome lists of open source software.

https://github.com/pdf-viewer-react/starter-rp-react-js-vite

React PDF Starter toolkit with React + JavaScript + Vite
https://github.com/pdf-viewer-react/starter-rp-react-js-vite

javascript pdf-viewer pdf-viewer-react pdfjs pdfjs-dist react-pdf react-pdf-viewer reactjs vite

Last synced: 4 months ago
JSON representation

React PDF Starter toolkit with React + JavaScript + Vite

Awesome Lists containing this project

README

          

# React PDF Starter Toolkit in React.js, JavaScript and Vite

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github.com/pdf-viewer-react/starter-rp-react-js-vite)

Welcome to the React PDF Starter Toolkit! This repository provides a comprehensive guide on integrating React PDF with React, JavaScript and Vite. It showcases how React PDF can be integrated and rendered as part of a React.js project.

## Table of Contents

- [Usage](#usage)
- [Project Setup](#project-setup)
- [Running the Example Project](#running-the-example-project)
- [Examples](#examples)

## Usage

### Project Setup

1. **Clone the Repository**: If you haven't already, clone the repository and navigate into the project directory.

```bash
git clone https://github.com/reactpdf/starter-rp-react-js-vite.git
cd starter-rp-react-js-vite
```

2. **Install Dependencies**: Install the necessary dependencies using npm, yarn, pnpm or bun.

```bash
npm install
# or
yarn install
# or
pnpm install
# or
bun install
```

### Running the Example Project

This repository includes an example project to demonstrate React PDF in action.

1. **Start the Development Server**: Use the following command to start the development server

```bash
npm run dev
# or
yarn dev
# or
pnpm run dev
# or
bun run dev
```

2. **Open in Browser**: Open your browser and navigate to `http://localhost:5173` (or the port specified in your terminal) to see the example project in action

### Using the React PDF Component

Once the example project is running, you can explore the source code to see how the React PDF component is integrated. Here is a brief overview:

1. **Import the component**: Import the desired React PDF component into your codes

```jsx
import { RPProvider, RPDefaultLayout, RPPages } from "@pdf-viewer/react";

export const AppPdfViewer = (props) => {
const { showToolbar = true, providerProps, defaultLayoutProps } = props;

return (

{showToolbar ? (



) : (




)}

);
};
```

2. **Use the component in the page**: Add the React PDF component to your page

```jsx
import { RPConfig } from "@pdf-viewer/react";
import { AppPdfViewer } from "./components/AppPdfViewer";

function App() {
return (


RP Starter Toolkit: Vite + React




Default Toolbar



Without Toolbar



Mobile





);
}

export default App;
```

## Examples

For more examples, please refer to the `src/App.jsx` file in this repository:

- Default Toolbar
- Without Toolbar
- Mobile View

_Remark: If you would like more examples, feel free open an issue._

For more configurations, please check the [documentation](https://docs.react-pdf.dev) site.

## Meta
- Homepage: [https://www.react-pdf.dev](https://www.react-pdf.dev)
- Docs: [https://docs.react-pdf.dev](https://docs.react-pdf.dev)

---

Thank you for using React PDF! We hope this toolkit helps you build amazing React.js applications. If you have any questions or need further assistance on this example, please feel free to open an issue. Happy coding!