4
怎么读取 pdf 的目录?
source link: https://www.v2ex.com/t/821089
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
怎么读取 pdf 的目录?
我想实现网页中展示 pdf 的目录,点击目录的某一项,才去动态加载对应的 pdf 一页。
用什么语言的什么库比较容易实现?
8 条回复 • 2021-12-09 17:12:35 +08:00
kujio 19 小时 18 分钟前
一般网站都是拆成图片的,目录的话提取 pdf 信息应该不是问题,
laravel 18 小时 35 分钟前
@SilentTiger nodejs 端处理吗?纯前端的不行,这样 pdf 就暴露了
laravel 18 小时 14 分钟前
我还是研究下 pdf 文件的结构吧,自己解析出来也行
Kasumi20 17 小时 59 分钟前
不是,这官方例子还不清楚吗,我都玩了一把了
```
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.js';
const pdfPath = String.raw`C:\Downloads\XXX-Manual.pdf`;
pdfjsLib.getDocument(pdfPath)
.promise
.then(function (doc) {
doc.getOutline().then(r => {
r.forEach(it => {
console.log(it.title);
});
})
});
```
输出:
1.软件介绍
2.安装运行
3.使用指南(管理员)
4. 统一编码规则
5. 授权的使用方法
6. 高级配置(仅限开发运维人员使用)
7.技术支持
```
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.js';
const pdfPath = String.raw`C:\Downloads\XXX-Manual.pdf`;
pdfjsLib.getDocument(pdfPath)
.promise
.then(function (doc) {
doc.getOutline().then(r => {
r.forEach(it => {
console.log(it.title);
});
})
});
```
输出:
1.软件介绍
2.安装运行
3.使用指南(管理员)
4. 统一编码规则
5. 授权的使用方法
6. 高级配置(仅限开发运维人员使用)
7.技术支持
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK