From fdaa7bd00e70dead72c68630d416ff318f74bf8b Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 21 Jul 2017 00:55:52 +0100 Subject: [PATCH] update readme (#2110) --- ng2-components/ng2-alfresco-viewer/README.md | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ng2-components/ng2-alfresco-viewer/README.md b/ng2-components/ng2-alfresco-viewer/README.md index d24bf7c644..8e4bb8cddf 100644 --- a/ng2-components/ng2-alfresco-viewer/README.md +++ b/ng2-components/ng2-alfresco-viewer/README.md @@ -35,6 +35,43 @@ necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2 npm install ng2-alfresco-viewer ``` +### Configuring PDF.js library + +In order to configure your webpack-enabled application with the PDF.js library please follow the next steps. + +Install pdfjs-dist + +```sh +npm install pdfjs-dist +``` + +Update `vendors.ts` by appending the following: + +```ts +// PDF.js +require('pdfjs-dist/web/compatibility.js'); +const pdfjsLib = require('pdfjs-dist'); +pdfjsLib.PDFJS.workerSrc = './pdf.worker.js'; +require('pdfjs-dist/web/pdf_viewer.js'); +``` + +The code above enables the "viewer" component and "compatibility" mode for all the browsers. +It also configures the web worker for PDF.js library to render PDF files in the background. + +Update the `plugins` section of the `webpack.common.js` file with the next lines: + +```js +new CopyWebpackPlugin([ + ... + { + from: 'node_modules/pdfjs-dist/build/pdf.worker.js', + to: 'pdf.worker.js' + } +]) +``` + +The Viewer component now should be able displaying PDF files. + ## Basic usage Using with node id: