4

怎么读取 pdf 的目录?

 2 years ago
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.
neoserver,ios ssh client

怎么读取 pdf 的目录?

V2EX  ›  程序员

怎么读取 pdf 的目录?

  laravel · 19 小时 52 分钟前 · 949 次点击

我想实现网页中展示 pdf 的目录,点击目录的某一项,才去动态加载对应的 pdf 一页。

用什么语言的什么库比较容易实现?

8 条回复    2021-12-09 17:12:35 +08:00

kujio

kujio      19 小时 18 分钟前

一般网站都是拆成图片的,目录的话提取 pdf 信息应该不是问题,

laravel

laravel      18 小时 35 分钟前

@SilentTiger nodejs 端处理吗?纯前端的不行,这样 pdf 就暴露了

laravel

laravel      18 小时 14 分钟前

我还是研究下 pdf 文件的结构吧,自己解析出来也行

Kasumi20

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.技术支持

laravel

laravel      17 小时 46 分钟前

@Kasumi20 我试试,谢谢

laravel

laravel      15 小时 49 分钟前

@Kasumi20 确实 pdf.js 强大啊,文章太多了,肯定能实现。

关于   ·   帮助文档   ·   API   ·   FAQ   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2822 人在线   最高记录 5497   ·  

创意工作者们的社区

World is powered by solitude

VERSION: 3.9.8.5 · 19ms · UTC 01:02 · PVG 09:02 · LAX 17:02 · JFK 20:02
♥ Do have faith in what you're doing.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK