vlx-react-pdf
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

React PDF viewer

A React component to view a PDF document. It's written in TypeScript, and powered by React hooks completely.

  1. Install packages
$ npm install pdfjs-dist@2.5.207
$ npm install vlx-react-pdf
  1. Import CSS and components
import Viewer, { Worker } from 'vlx-react-pdf';
import 'vlx-react-pdf/cjs/react-pdf-viewer.css';
  1. Use the component
<Worker workerUrl="https://unpkg.com/pdfjs-dist@2.5.207/build/pdf.worker.min.js">
    <div style={{ height: '750px' }}>
        <Viewer fileUrl="/path/to/document.pdf" />
    </div>
</Worker>

Commands

  1. Build:
$ npm run build

Then it will produce two formats available in the dist folder:

└─── dist
    ├─── cjs    // CommonJS package
    └─── umd    // UMD package
  1. Dev mode:
$ npm run dev

The bundler will watch the entire src folder and build the cjs package when any source file is changed.

  1. Lint:
$ npm run lint

It will check if the entire source code compatible with

Package Sidebar

Install

npm i vlx-react-pdf

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

628 kB

Total Files

12

Last publish

Collaborators

  • lpianciola