├── LICENSE
├── README.md
├── demo
├── example1.pdf
├── example2.pdf
├── ignore.template
├── index.html
├── index.js
├── package.json
└── src
│ └── index.js
├── ignore.template
├── index.js
├── package.json
├── screenshot.png
└── src
└── index.js
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Description
2 |
3 | This is Simple PDF React component with vertical scroll bar. However, If your pdf document has only one page there will not be any scroll bar by default. If you still need scroll bars, just use CSS example (see demo [index.html](https://github.com/javascriptiscoolpl/npm-simple-react-pdf/blob/master/demo/index.html) code for more details).
4 |
5 | This version uses [pdfjs-dist](https://www.npmjs.com/package/pdfjs-dist) (npm [PDF.js](https://mozilla.github.io/pdf.js/) version) and ES6 syntax. Has been built with [Babel](https://babeljs.io/) and contains demo built with [Browserify](http://browserify.org/).
6 |
7 | Screenshot example (3 x Simple PDF React component):
8 |
9 | 
10 |
11 | # Install
12 |
13 | npm install simple-react-pdf
14 |
15 | However, in production or if you do not plan to re-build it, do not install devDependencies. See [npm documentation page](https://docs.npmjs.com/cli/install).
16 |
17 | # Usage - quickstart
18 |
19 | ##### index.html
20 |
21 | This is simple example that should be used in most cases. The pdf size (each canvas) will be automatically adjusted to the box size (div with class SimplePDF).
22 |
23 | .SimplePDF {
24 | width: 350px; /* width of pdf document box should be != 0 */
25 | height: 500px; /* height of pdf document box should be != 0 */
26 | border: 1px dashed red; /* optional */
27 | margin: 15px; /* optional */
28 | padding: 15px; /* optional */
29 | float: left; /* optional */
30 | }
31 |
32 | ##### index.js
33 |
34 | The JavaScript React component code you have to use in your project:
35 |
36 | import React from "react";
37 | import ReactDOM from "react-dom";
38 | import spdf from "simple-react-pdf";
39 |
40 |
41 |
42 | *) Of course change the "example1.pdf" to your pdf document filename and re-build the JavaScript code.
43 |
44 | # Usage - with update
45 |
46 | To update React component (e.g. load new pdf file after button click), you just have to send new props to the React component again (see demo [index.js](https://github.com/javascriptiscoolpl/npm-simple-react-pdf/blob/master/demo/src/index.js) for more details).
47 |
48 | # Demo
49 |
50 | The demo is available in module directory. To test the demo just go to demo directory in module folder and open index.html in your browser.
51 |
52 | cd node_modules/simple-react-pdf/demo
53 | firefox index.html
54 |
55 | For other browsers:
56 |
57 | google-chrome --allow-file-access-from-files index.html
58 | opera --allow-file-access-from-files index.html
59 |
60 | In order to avoid [Cross-Origin Resource Sharing (CORS) issue](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-xhr) consider [simple-react-pdf-service](https://www.npmjs.com/package/simple-react-pdf-service).
61 |
62 | # Demo re-build
63 |
64 | However, you can build the demo again with npm tool (e.g. after your private changes). To re-build the demo just go to demo directory in module folder (if you are not there already):
65 |
66 | cd node_modules/simple-react-pdf/demo
67 |
68 | and run command:
69 |
70 | npm run build
71 |
72 | This should download all packages and build the demo index.js file again. After it, you can open index.html in your browser. Should work :-)
73 |
74 | # License
75 |
76 | MIT
77 |
--------------------------------------------------------------------------------
/demo/example1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javascriptiscoolpl/npm-simple-react-pdf/9c6bc06f99a650d63c70a2bb8b0e4b94663f9818/demo/example1.pdf
--------------------------------------------------------------------------------
/demo/example2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javascriptiscoolpl/npm-simple-react-pdf/9c6bc06f99a650d63c70a2bb8b0e4b94663f9818/demo/example2.pdf
--------------------------------------------------------------------------------
/demo/ignore.template:
--------------------------------------------------------------------------------
1 | ./node_modules
2 | .git
3 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |