node.js - 当 URL 作为参数传递给 .getDocument() 时,PDF.js 上缺少 PDF 错误
问题描述
我正在尝试访问一系列 PDF 链接并打印出它们的页数。目前,我正在 NodeJS localhost Web 服务器上尝试此代码,但出现此错误,message: 'Missing PDF "https://www.nice.com/Lists/PressReleases/Attachments/226/q2_2021_pr.pdf".', name: 'MissingPDFException'.
谁能帮我解决这个问题?此链接上有一个 PDF,在浏览器中导航到时可以看到。
for (const pdfLink of pdfLinks) {
console.log(pdfLink);
let document = await pdfJS.getDocument(encodeURIComponent(pdfLink))
.promise;
let numberOfPages = document.numPages;
console.log(numberOfPages);
}
} catch (error) {
console.log(error);
}
解决方案
推荐阅读
- typescript - 在字符串值成员中使用枚举
- performance - 如何在 KQL 中使用服务器获取顶级 CPU 的详细信息
- html - 当元素可见和不可见时,CSS Flexbox 在不同的行中显示元素
- json - JSON文件中的超链接值
- javascript - 我想在 MVC UI 的剑道网格中选择展开和折叠行
- json - 从 JSON 值中过滤某些(子)键
- flutter - 无法将所有图像从 Android 发送到颤动
- ninject - 在 Ninject 中使用 Autofac
- arrays - 如何为嵌套在数组中的文档中的字段设置唯一约束?
- json - 使用jq将子文件合并到主文件中