react-pdf-js
Advanced tools
Comparing version 1.0.25 to 1.0.26
@@ -226,3 +226,3 @@ 'use strict'; | ||
if (!!props.file) { | ||
if (props.file) { | ||
var _ret = function () { | ||
@@ -245,3 +245,3 @@ if (typeof props.file === 'string') { | ||
this.loadByteArray(props.binaryContent); | ||
} else if (!!props.content) { | ||
} else if (props.content) { | ||
var bytes = window.atob(props.content); | ||
@@ -254,3 +254,3 @@ var byteLength = bytes.length; | ||
this.loadByteArray(byteArray); | ||
} else if (!!props.documentInitParameters) { | ||
} else if (props.documentInitParameters) { | ||
return this.getDocument(props.documentInitParameters); | ||
@@ -285,3 +285,3 @@ } else { | ||
// Main loop deals with bytes in chunks of 3 | ||
for (var i = 0; i < mainLength; i = i + 3) { | ||
for (var i = 0; i < mainLength; i += 3) { | ||
// Combine the three bytes into a single integer | ||
@@ -330,3 +330,3 @@ chunk = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2]; | ||
if (page) { | ||
var canvas = this.refs.canvas; | ||
var canvas = this.canvas; | ||
@@ -345,6 +345,10 @@ var canvasContext = canvas.getContext('2d'); | ||
value: function render() { | ||
var _this3 = this; | ||
var loading = this.props.loading; | ||
var page = this.state.page; | ||
return page ? _react2.default.createElement('canvas', { ref: 'canvas' }) : loading || _react2.default.createElement( | ||
return page ? _react2.default.createElement('canvas', { ref: function ref(c) { | ||
return _this3.canvas = c; | ||
} }) : loading || _react2.default.createElement( | ||
'div', | ||
@@ -351,0 +355,0 @@ null, |
{ | ||
"name": "react-pdf-js", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "A React component to wrap PDF.js", | ||
@@ -33,3 +33,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"pdfjs-dist": "1.5.361" | ||
"pdfjs-dist": "1.5.365", | ||
"react": "15.3.0" | ||
}, | ||
@@ -42,3 +43,3 @@ "devDependencies": { | ||
"babel-plugin-react-transform": "2.0.2", | ||
"babel-plugin-transform-runtime": "6.9.0", | ||
"babel-plugin-transform-runtime": "6.12.0", | ||
"babel-plugin-typecheck": "3.9.0", | ||
@@ -48,8 +49,7 @@ "babel-preset-es2015": "6.9.0", | ||
"babel-runtime": "6.11.6", | ||
"eslint": "2.13.1", | ||
"eslint-config-airbnb": "9.0.1", | ||
"eslint": "3.2.2", | ||
"eslint-config-airbnb": "10.0.0", | ||
"eslint-plugin-import": "1.12.0", | ||
"eslint-plugin-react": "5.2.2", | ||
"eslint-plugin-jsx-a11y": "1.5.5", | ||
"react": "15.2.1", | ||
"eslint-plugin-react": "6.0.0", | ||
"eslint-plugin-jsx-a11y": "2.0.1", | ||
"rifraf": "2.0.2", | ||
@@ -56,0 +56,0 @@ "rimraf": "2.5.4", |
import Pdf from './Pdf'; | ||
export default Pdf; |
import React from 'react'; | ||
require('pdfjs-dist/build/pdf.combined'); | ||
@@ -138,3 +139,3 @@ require('pdfjs-dist/web/compatibility'); | ||
loadPDFDocument(props) { | ||
if (!!props.file) { | ||
if (props.file) { | ||
if (typeof props.file === 'string') { | ||
@@ -150,3 +151,3 @@ return this.getDocument(props.file); | ||
this.loadByteArray(props.binaryContent); | ||
} else if (!!props.content) { | ||
} else if (props.content) { | ||
const bytes = window.atob(props.content); | ||
@@ -159,3 +160,3 @@ const byteLength = bytes.length; | ||
this.loadByteArray(byteArray); | ||
} else if (!!props.documentInitParameters) { | ||
} else if (props.documentInitParameters) { | ||
return this.getDocument(props.documentInitParameters); | ||
@@ -187,3 +188,3 @@ } else { | ||
// Main loop deals with bytes in chunks of 3 | ||
for (let i = 0; i < mainLength; i = i + 3) { | ||
for (let i = 0; i < mainLength; i += 3) { | ||
// Combine the three bytes into a single integer | ||
@@ -230,3 +231,3 @@ chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]; | ||
if (page) { | ||
const { canvas } = this.refs; | ||
const { canvas } = this; | ||
const canvasContext = canvas.getContext('2d'); | ||
@@ -244,3 +245,3 @@ const { scale } = this.props; | ||
const { page } = this.state; | ||
return page ? <canvas ref="canvas" /> : loading || <div>Loading PDF...</div>; | ||
return page ? <canvas ref={c => this.canvas = c} /> : loading || <div>Loading PDF...</div>; | ||
} | ||
@@ -247,0 +248,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2638978
18
54230
2
+ Addedreact@15.3.0
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpdfjs-dist@1.5.365(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedreact@15.3.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.40(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
- Removedpdfjs-dist@1.5.361(transitive)
Updatedpdfjs-dist@1.5.365