I have an angular2 app, where I want the user to be able to download and open a pdf file in the browser.
Is there an angular2 module or component that I can use?
If you want do display a base 64 pdf you can use my component https://www.npmjs.com/package/ng2-image-viewer
It works with angular 2+ and it renders Base 64 images, URL Images and Base 64 PDFs, it's easy to implement, you just have to:
1) Run npm install ng2-image-viewer --save
2) Add these codes on your angular-cli.json file:
"styles": [
"../node_modules/ng2-image-viewer/imageviewer.scss"
],
"scripts": [
"../node_modules/ng2-image-viewer/imageviewer.js"
],
3) Import ImageViewerModule
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Specify your library as an import
ImageViewerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
4) Now you can use it as you wish:
Image Viewer
Here is a demo of it Ng2-Image-Viewer Showcase
For more info you can check the link above :)