本帖最后由 三闪五月 于 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); |