Skip to content

OSBI/saiku-react-pdfjs

Repository files navigation

Saiku React PDF.js

A React component to wrap PDF.js.

npm downloads npm version npm license

Requirements

  • Node.js v6.0.0 or higher
  • NPM (v3.0.0+ recommended) (this comes with Node.js)

Installation

Using NPM:

npm install --save saiku-react-pdfjs

Using Yarn:

yarn add saiku-react-pdfjs

Usage

Here's an example of basic usage:

import React, { Component } from 'react';
import SaikuPDF from 'saiku-react-pdfjs';

class MyApp extends Component {
  constructor(props) {
    super(props);

    this.onDocumentComplete = this.onDocumentComplete.bind(this);
    this.onPageComplete = this.onPageComplete.bind(this);
  }

  onDocumentComplete(numberOfPages, pdf) {
    this.setState({ numberOfPages });
  },

  onPageComplete(currentPage, page) {
    this.setState({ currentPage });
  }

  render() {
    return (
      <div>
        <SaikuPDF
          file="someFile.pdf"
          page={2}
          scale={1}
          onDocumentComplete={this.onDocumentComplete}
          onPageComplete={this.onPageComplete}
        />
        <p>Page {this.state.currentPage} of {this.state.numberOfPages}</p>
      </div>
    );
  }
}

export default MyApp;

Storybook

You can access saiku-react-pdfjs storybook here.

Contributing

If you want to help, please read the Contributing guide.

History

For detailed changelog, see Releases.

Credits

Big thanks to these great repositories:

License

Apache License Version 2 © Meteorite BI