Socket
Socket
Sign inDemoInstall

react-pdf

Package Overview
Dependencies
34
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-pdf

A react component using pdf.js to display pdf documents inline


Version published
Maintainers
1
Install size
5.29 MB
Created

Readme

Source

react-pdf

What

A component for showing a pdf page using pdf.js.

Usage

Install with npm install react-pdf

Use in your app:

var PDF = require('react-pdf');

var MyApp = React.createClass({
  render: function() {
    
    return <PDF file="somefile.pdf" page="2" />
  },
  _onPdfCompleted: function(page, pages){
    this.setState({page: page, pages: pages});
  }
});

or

var PDF = require('react-pdf');

var MyApp = React.createClass({
  render: function() {
    
    return <PDF content="YSBzaW1wbGUgcGRm..." page="1" scale="1.0" onDocumentComplete={this._onDocumentComplete} onPageComplete={this._onPageComplete} loading={(<span>Your own loading message ...</span>)} />
  },
  _onDocumentCompleted: function(pages){
    this.setState({pages: pages});
  },
  _onPageCompleted: function(page){
    this.setState({currentPage: page});
  }
});

Check the example-directory of this repository for a full working example

Pitfalls

Unfortunately pdf.js isn't too friendly for commonjs environments so react-pdf assumes a global PDFJS variable, see the example directory of this repository for an example.

License

The MIT License

Author

Niklas Närhinen niklas@narhinen.net

Bart Van Houtte bart.van.houtte@ading.be Added Base64 Content , update PDFJS, document and page completion notification callbacks and custom loading message

Keywords

FAQs

Last updated on 29 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc