@@ -16,8 +16,14 @@ class Pdf extends React.Component {
1616
1717 componentWillReceiveProps ( newProps ) {
1818 const { pdf } = this . state ;
19+
20+ const newDocInit = newProps . documentInitParameters ;
21+ const docInit = this . props . documentInitParameters ;
22+
1923 if ( ( newProps . file && newProps . file !== this . props . file ) ||
20- ( newProps . content && newProps . content !== this . props . content ) ) {
24+ ( newProps . content && newProps . content !== this . props . content ) ||
25+ ( newDocInit && newDocInit !== docInit ) ||
26+ ( newDocInit && docInit && newDocInit . url !== docInit . url ) ) {
2127 this . loadPDFDocument ( newProps ) ;
2228 }
2329
@@ -69,6 +75,9 @@ class Pdf extends React.Component {
6975 byteArray [ index ] = bytes . charCodeAt ( index ) ;
7076 }
7177 this . loadByteArray ( byteArray ) ;
78+ } else if ( ! ! props . documentInitParameters ) {
79+ return window . PDFJS . getDocument ( props . documentInitParameters )
80+ . then ( this . onDocumentComplete ) ;
7281 } else {
7382 throw new Error ( 'react-pdf-js works with a file(URL) or (base64)content. At least one needs to be provided!' ) ;
7483 }
@@ -97,6 +106,7 @@ Pdf.displayName = 'react-pdf-js';
97106Pdf . propTypes = {
98107 content : React . PropTypes . string ,
99108 file : React . PropTypes . string ,
109+ documentInitParameters : React . PropTypes . object ,
100110 loading : React . PropTypes . any ,
101111 page : React . PropTypes . number ,
102112 scale : React . PropTypes . number ,
0 commit comments