📅  最后修改于: 2023-12-03 15:17:52.750000             🧑  作者: Mango
ngx-doc-viewer is a lightweight library for Angular that allows you to display documents in your web application. It supports various document formats including PDF, Microsoft Office documents, and images.
Some of the notable features of ngx-doc-viewer are:
You can install ngx-doc-viewer using npm:
npm install --save ngx-doc-viewer
To use ngx-doc-viewer, you need to import it into your Angular module and add it to your template HTML file. Here's an example:
import { NgModule } from '@angular/core';
import { NgxDocViewerModule } from 'ngx-doc-viewer';
@NgModule({
declarations: [AppComponent],
imports: [NgxDocViewerModule],
bootstrap: [AppComponent]
})
export class AppModule { }
<ngx-doc-viewer [documentUrl]="documentUrl" [options]="options"></ngx-doc-viewer>
You can customize the behavior of ngx-doc-viewer by passing options as an input to the component instance. Here are some of the available options:
options = {
// Height of viewer container
height: '600px',
// Enable/disable printing feature
showPrint: true,
// Enable/disable download feature
showDownload: true,
// Enable/disable fullscreen feature
fullscreen: true,
// Enable/disable zooming feature
zoom: true,
// Maximum zoom level
maxZoom: 3,
// Minimum zoom level
minZoom: 0.5,
// Start zoom level.
initialZoom: 1,
// Mode of view - full-width, full-height or original size
mode: 'full-width',
// Text appear while loading document
loadingMessage: 'Loading the document. Please wait...'
};
ngx-doc-viewer is a powerful tool for displaying documents in your Angular application. It's easy to use, customizable, and supports various document formats. With ngx-doc-viewer, you can provide a seamless document-viewing experience to your users.