吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2359|回复: 11
收起左侧

[其他转载] 【javascript】利用javascript 将pdf书签转化成目录(带页码)

  [复制链接]
三闪五月 发表于 2022-6-21 22:27
本帖最后由 三闪五月 于 2022-6-21 22:36 编辑

用adobe acrobat Pro打开PDF文件,在“工具 ”-“JavaScript”-“文档级 JavaScript”中,添加 JavaScript脚本,可将pdf书签导出为PDF格式带页码的目录页。
[JavaScript] 纯文本查看 复制代码
function PrintBookmarks(bm, nLevel)
{
    if (nLevel != 0) { // don't print the root
        bmReport.absIndent=bmTab*(nLevel-1);
        bm.execute();
        bmReport.writeText(bm.name+".........."+(bm.doc.pageNum +1));
     }
    if (bm.children != null)
     for (var i = 0; i < bm.children.length; i++)
        PrintBookmarks(bm.children[i], nLevel + 1);
}
bmTab = 20;
bmReport = new Report();
bmReport.size = 2;
bmReport.writeText(this.title);
bmReport.writeText(" ");
bmReport.size = 1.5;
bmReport.writeText("目录");
bmReport.writeText(" ");
bmReport.size = 1;
PrintBookmarks(this.bookmarkRoot, 0);
global.bmRep = bmReport;  // make global
global.wrtDoc = app.setInterval(
   'try {'
   +'       reportDoc = global.bmRep.open("Listing of Bookmarks");'
   +'       console.println("Executed Report.open");'
   +'       app.clearInterval(global.wrtDoc);'
   +'       delete global.wrtDoc;'
   +'       console.println("Executed App.clearInterval");'
   +'       reportDoc.info.title = "Bookmark Listings";'
   +'       reportDoc.info.Author = "List Bookmark Sequence";'
   +'} catch (e) {console.println("Waiting...: " + e);}'
   , 100);

免费评分

参与人数 3吾爱币 +3 热心值 +3 收起 理由
songxp03 + 1 + 1 我很赞同!
为之奈何? + 1 + 1 我很赞同!
De蓝 + 1 + 1 热心回复!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 三闪五月 发表于 2022-6-22 08:23
平淡最真 发表于 2022-6-21 23:21
统计下标题和页码长度,最后计算下点的个数,把格式对齐

对。包括行距、字号、目录居中等可以再细化。
平淡最真 发表于 2022-6-21 23:21
统计下标题和页码长度,最后计算下点的个数,把格式对齐
jgpy 发表于 2022-6-21 23:40
kanxue2018 发表于 2022-6-22 01:45

感谢楼主分享
songxp03 发表于 2022-6-22 06:47
原来是有个js api啊
ysjd22 发表于 2022-6-22 06:58
楼主高明啊。
木楚子潺 发表于 2022-6-22 07:42
可以可以
worni 发表于 2022-6-22 09:20
过来 看看
yhzh 发表于 2022-6-22 10:06
感谢分享。。。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-28 16:34

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表