使用Acrobat Pro和JavaScript:将PDF转换为带页码目录的神奇操作

随心笔谈11个月前更新 admin
75 0

1、首先需要安装adobe acrobat Pro,下载地址:https://pan.baidu.com/s/1PD1sCryujYjjsJRDVqo6yw?pwd=0q99

2、用adobe acrobat Pro打开PDF文件

3、在“工具 ”-“JavaScript”-“文档级 JavaScript”中,添加 JavaScript脚本,可将pdf书签导出为PDF格式带页码的目录页。

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);

© 版权声明

相关文章