【发布时间】:2023-01-06 21:35:20
【问题描述】:
I have tested different libraries like ng2 pdf viewer/ ng extended pdf viewer. The problem is that doesn't work with images I want to use one library to view images and pdf's
【问题讨论】:
I have tested different libraries like ng2 pdf viewer/ ng extended pdf viewer. The problem is that doesn't work with images I want to use one library to view images and pdf's
【问题讨论】:
You can use a third-party library that supports both images and PDFs, the Angular Media Viewer library, which supports a variety of media types including images, PDFs, and videos.
To use the Angular Media Viewer library, you will need to install it using npm:
npm install @ngx-media/viewer
Then, you can import the NgxMediaViewerModule in your Angular module and use the component to display a variety of media types in your template.
import { NgxMediaViewerModule } from '@ngx-media/viewer';
@NgModule({
imports: [
NgxMediaViewerModule
]
// ...
})
export class AppModule { }
You can then use it as below in HTML.
<ngx-media-viewer [src]="/path/to/image.jpg" [type]="'image'"></ngx-media-viewer>
<ngx-media-viewer [src]="/path/to/document.pdf" [type]="'pdf'"></ngx-media-viewer>
I hope this helps!
【讨论】: