如何在Angular 2/4/5中使用PDF.js? [英] How to use PDF.js in Angular 2/4/5?
问题描述
我正在尝试使用Mozilla的PDF.js (此处为示例)来开发PDfViewer应用程序).如果有任何github项目作为参考,那就太好了.
I'm trying to develop PDfViewer Application using Mozilla's PDF.js (example here). It would be great if there is any github project as a reference.
感谢提前!
推荐答案
如果不是必须使用Mozilla的PDF.js,则可以使用ng2-pdf-viewer npm模块,该模块在后台使用PDF.js.您可以按照以下步骤开始
If it is not a must to use Mozilla's PDF.js then you can use ng2-pdf-viewer npm module which uses PDF.js in background. You can start of it with following steps
安装
npm install ng2-pdf-viewer --save
注意:对于角度为4或更低的版本,请使用版本3.0.8
Note: For angular 4 or less use version 3.0.8
然后,将模块导入app.module.js
Then, import the module in app.module.js
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({
imports: [BrowserModule, PdfViewerModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
然后在组件中使用它
@Component({
selector: 'example-app',
template: `
<pdf-viewer [src]="pdfSrc"
[render-text]="true"
style="display: block;">
</pdf-viewer>
})
有关更多详细信息,请参考下面的git URL和演示URL.
For more details, refer the below git URL and the demo URL.
https://github.com/VadimDez/ng2-pdf-viewer
https://vadimdez.github.io/ng2-pdf-viewer/
希望这对您有所帮助.
这篇关于如何在Angular 2/4/5中使用PDF.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!