我想在角项目中使用pdfjs软件包。如何导入它的角度项目
我用
npm install --save pdfjs-dist
但不知道如何导入特定组件并使用它
发布于 2019-11-06 11:13:34
在package.json中安装它之后,如下所示
"dependencies": {
...
"pdfjs-dist": "^2.2.228",
...
}1)现在在组件中,您可以像
import * as pdfjsLib from 'pdfjs-dist';2)现在你可以像下面的例子那样使用它
yourMethodName() {
pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
const loadingTask = pdfjsLib.getDocument('https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf');
loadingTask.promise.then(function(pdf) {
console.log(pdf);
});
}https://stackoverflow.com/questions/58728223
复制相似问题