Updated Setup PDF.js in a website (markdown)

Tim van der Meij 2019-11-27 23:25:20 +01:00
parent 2d0b49bd9d
commit 050331840a

@ -1,17 +1,21 @@
You can choose to use a pre-built version of PDF.js or build PDF.js from source.
## Pre-built PDF.js
### With npm
### Official releases
Add the dependencies to your project:
The official releases from https://github.com/mozilla/pdf.js/releases include the generic build of PDF.js and the viewer. This is most likely the best choice if you're not aiming to build your own viewer. The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. <em>However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it.</em>
### NPM
Install the PDF.js dependency in your project:
npm install pdfjs-dist --save
You can find a usage example at https://github.com/mozilla/pdf.js/blob/master/examples/node/getinfo.js.
#### With Webpack
#### Webpack
Add the dependencies to your project:
Install the PDF.js dependency in your project:
npm install pdfjs-dist --save-dev
@ -19,9 +23,9 @@ To use the library in your project add `require('pdfjs-dist')` to your file requ
Refer to https://github.com/mozilla/pdf.js/tree/master/examples/webpack for a complete example.
#### With Browserify
#### Browserify
Add the dependencies to your project:
Install the PDF.js dependency in your project:
npm install pdfjs-dist --save-dev
@ -29,7 +33,7 @@ To use the library in your project add `require('pdfjs-dist')` to your file requ
Refer to https://github.com/mozilla/pdf.js/tree/master/examples/browserify for a complete example.
### From examples
### Examples
When the source code of PDF.js changes, the [online demo](http://mozilla.github.io/pdf.js/web/viewer.html) is automatically updated. The source of all demo files can easily be accessed at https://github.com/mozilla/pdf.js/tree/gh-pages. These files can also be uploaded to your server to use PDF.js to display PDF files from your website.
1. Download https://github.com/mozilla/pdf.js/archive/gh-pages.zip.
@ -44,7 +48,7 @@ When the source code of PDF.js changes, the [online demo](http://mozilla.github.
<a href="/web/viewer.html?file=%2Fyourpdf.pdf">Open yourpdf.pdf with PDF.js</a>
```
The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. *However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it.*
Similar to the official releases, we ask you to re-skin it or build upon it before deploying it.
## Build PDF.js from source
After cloning PDF.js, you can build PDF.js from source by running `gulp generic` in Git Bash or another terminal. This will create the built PDF.js in the `build` folder, which you can upload to your server.
After cloning PDF.js, you can build PDF.js from source by running the `gulp generic` coomand. This will create the built PDF.js in the `build` folder.