See it live: Viewer Quickstart
Before you start using this development framework, make sure you have installed all required software and done all the necessary configuration prerequisites.
If you plan using this component with projects generated by Angular CLI, please refer to the following article: Using ADF with Angular CLI
npm install ng2-alfresco-viewer
In order to configure your webpack-enabled application with the PDF.js library please follow the next steps.
npm install pdfjs-dist
vendors.ts by appending the following:
// PDF.jsrequire('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.
plugins section of the
webpack.common.js file with the next lines:
...from: 'node_modules/pdfjs-dist/build/pdf.worker.js'to: 'pdf.worker.js'
The Viewer component now should be able displaying PDF files.
Using with node id:
Using with file url:
|fileNodeId||string||Node Id of the file to load|
|urlFile||string||If you want to load an external file that does not come from ECM you can use this Url where to load the file|
|urlBlob||Blob||If you want to load a Blob File|
|showViewer||boolean||true||Hide or show the viewer|
|showToolbar||boolean||true||Hide or show the toolbars|
|displayName||string||You can specify the name of the file|
|Media||wav, Mp3, Mp4, WebM, Ogv|
|Images||png, jpg, jpeg, gif, bmp|
Note for unsupported extensions the viewer will offer the possibility to convert to PDF if that kind of extension is supported by the content service renditions service
If you want to handle other file formats that are not yet supported by the ng2-alfresco-viewer you can define your own custom handler.
Below you can find an example with the use of
extension-viewer if you can handle 3d files
Note: you need adding
ng2-3d-editor dependency to your
package.json file to make the example above work.
It is possible to define multiple
You can build component from sources with the following commands:
npm installnpm run build
buildtask rebuilds all the code, runs tslint, license checks and other quality check tools before performing unit testing.
|npm run build||Build component|
|npm run test||Run unit tests in the console|
|npm run test-browser||Run unit tests in the browser|
|npm run coverage||Run unit tests and display code coverage report|
Please check the demo folder for a demo project
cd demonpm installnpm start