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

https://github.com/react-pdf-kit/starter-rp-docusaurus-ts

React PDF Kit Starter Toolkit with Docusaurus and TypeScript
https://github.com/react-pdf-kit/starter-rp-docusaurus-ts

docusaurus pdf-viewer pdf-viewer-react pdfjs pdfjs-dist react react-pdf react-pdf-kit react-pdf-viewer reactjs typescript

Last synced: about 1 month ago
JSON representation

React PDF Kit Starter Toolkit with Docusaurus and TypeScript

Awesome Lists containing this project

README

          

# React PDF Kit Starter Toolkit in Docusaurus and TypeScript

[![Open example in codesandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/github/react-pdf-kit/starter-rp-docusaurus-ts/main)

Welcome to the React PDF Kit Starter Toolkit! This repository provides a comprehensive guide on integrating React PDF with Docusaurus and TypeScript. It showcases how the React PDF Viewer component 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/react-pdf-kit/starter-rp-docusaurus-ts.git
cd starter-rp-docusaurus-ts.git
```

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 Kit in action.

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

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

By default, the dev server runs on `http://localhost:3000`.

### 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

```tsx
import {
RPLayout,
RPLayoutProps,
RPPages,
RPProvider,
RPProviderProps,
} from "@react-pdf-kit/viewer";
import React, { type FC } from "react";

interface IProps {
showToolbar: boolean;
providerProps: Omit;
defaultLayoutProps: RPLayoutProps;
}

const DEFAULT_PDF_URL =
"https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf";

const AppPdfViewer: FC> = (props) => {
const { showToolbar = true, providerProps, defaultLayoutProps } = props;
return (



{showToolbar ? (



) : (



)}


);
};

export default AppPdfViewer;
```

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

```tsx
import type { ReactNode } from "react";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import { RPConfig } from "@react-pdf-kit/viewer";
import AppPdfViewer from "../components/AppPdfViewer";

export default function Home(): ReactNode {
const { siteConfig } = useDocusaurusContext();
return (


{siteConfig.title}




Default Toolbar





Without Toolbar





Mobile





);
}
```

## Examples

For more examples, please refer to the `src/pages/index.tsx` 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-kit.dev/) site.

## Meta

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

---

Thank you for using React PDF Kit! 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!