【问题标题】:Angular PDF / Image Viewer LibraryAngular PDF / Image Viewer Library
【发布时间】: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

【问题讨论】:

    标签: angular angular-library


    【解决方案1】:

    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!

    【讨论】:

      猜你喜欢
      • 2013-10-28
      • 2022-07-26
      • 2019-06-03
      • 2021-12-27
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      相关资源
      最近更新 更多