经典如何给PDF文件添加书签
更新时间:2023-04-23 03:44:01 阅读量: 实用文档 文档下载
最近经常看一些PDF的电子文档,痛苦的是Adobe Reader竟然没有提供书签的功能,每次看完之后再回到上次看的地方都很麻,到网上一找,还真有人就做了PDF的书签,下载一试效果不错,于是参看了一下Adobe Reader的SDK,修改了一点地方,防止了乱码,以更方便的使用,下面是程序的使用方法
1、打开编辑的首选项项
2、确保下面的选项都被选中
3 把下面的代码保存为一个bookmark_page.js文件
varbp_delim= '%#%#';
functionSaveData( data )
{
// data is an array of arrays that needs
// to be serialized and stored into a persistent
// global string
var ds= '';
data.sort();
for( ii= 0; ii<data.length; ++ii )
{
for(jj= 0; jj< 3; ++jj )
{
if( ii!= 0 || jj!= 0 )
ds+= bp_delim;
ds+= data[ii][jj];
}
}
global.pdf_hacks_js_bookmarks= ds;
global.setPersistent( "pdf_hacks_js_bookmarks", true );
}
functionGetData()
{
// reverse of SaveData; return an array of arrays
if(global.pdf_hacks_js_bookmarks== null )
{
return new Array(0);
}
var flat= global.pdf_hacks_js_bookmarks.split( bp_delim );
var data= new Array();
for( ii= 0; ii<flat.length; )
{
var record= new Array();
for(jj= 0; jj< 3 && ii<flat.length; ++ii, ++jj )
{
record.push( flat[ii] );
}
if(record.length== 3 )
{
data.push( record );
}
}
return data;
}
//Get Current Date
functionDateNow()
{
var d, tmp ,s ;
d = new Date();
t = d.getFullYear();
s = t + "/";
t = (d.getMonth() + 1).toString();
if(t.length!=2) t = "0" + t;
s += t + "/";
t = (d.getDate()).toString();
if(t.length!=2) t = "0" + t;
s += t;
return(s);
}
functionAddBookmark()
{
// query the user for a name, and then combine it with
// the current PDF page to create a record; store this record varthisfilename=this.documentFileName;
thisfilename=thisfilename.substr(0,stIndexOf(".")); varnumLen = this.numPages.toString().length;
varnumPlugInss=this.pageNum+1;
while(numPlugInss.toString().length <numLen)
{
numPlugInss = "0" + numPlugInss;
}
varcurrentdate=DateNow();
var label="《"+thisfilename+"》第 "+numPlugInss+" 页/共
"+this.numPages+" 页 " + currentdate;
varcResponse = app.response(
{ cQuestion: label, cTitle: "添加书签", cDefault: "无备注",
cLabel: "备注:"
});
if(cResponse!= null )
{
var record= new Array(3);
record[0]= label + " " + cResponse;
record[1]= this.path;
record[2]= this.pageNum;
data= GetData();
data.push( record );
SaveData( data );
}
}
functionShowBookmarks()
{
// show a pop-up menu; this seems to only work when
// a PDF is alreay in the viewer;
var data= GetData();
var items= '';
for( ii= 0; ii<data.length; ++ii )
{
if( ii!= 0 )
items+= ', ';
items+= '"'+ ii+ ': '+ data[ii][0]+ '"';
}
// assemble the command and the execute it with eval()
var command= 'app.popUpMenu( '+ items+ ' );';
var selection= eval( command );
if( selection== null )
{
return; // exit
}
// the user made a selection; parse out its index and use it // to access the bookmark record
var index= 0;
// toString() converts the String object to a string literal // eval() converts the string literal to a number
index= eval( selection.substring( 0,
selection.indexOf(':') ).toString() );
if( index<data.length )
{
try
{
// the document must be 'disclosed' for us to have any access // to its properties, so we use these FirstPageNextPage calls //
if(this.path == data[index][1]) { } else { } varotherDoc = app.openDoc( data[index][1]); otherDoc.pageNum = data[index][2]; this.pageNum= data[index][2];
}
catch(ee )
{
var response=
app.alert("打开书签错误. 是否删除本书签?", 2, 2,"删除书签"); if( response== 4 && index<data.length )
{
data.splice( index, 1 );
SaveData( data );
}
}
}
}
functionDropBookmark()
{
// modelled after ShowBookmarks()
var data= GetData();
var items= '';
for( ii= 0; ii<data.length; ++ii )
{
if( ii!= 0 )
items+= ', ';
items+= '"'+ ii+ ': '+ data[ii][0]+ '"';
}
var command= 'app.popUpMenu( '+ items+ ' );';
var selection= eval( command );
if( selection== null )
{
return; // exit
}
var index= 0;
index= eval( selection.substring( 0,
selection.indexOf(':') ).toString() );
if( index<data.length )
{
data.splice( index, 1 );
SaveData( data );
}
}
functionClearBookmarks()
{
if( app.alert("确认要清除所有的书签吗,删除后将不可恢复?", 2, 2,"删除书签" )== 4 )
{
SaveData( new Array(0) );
}
}
app.addMenuItem(
{
cName: "-", // menu pider
cParent: "View", // append to the View menu
cExec: "void(0);"
} );
app.addMenuItem(
{
cName: "AddBookmark",
cUser: "设置本页为书签(&B)",
cParent: "View",
cExec: "AddBookmark();",
cEnable: "event.rc= (event.target != null);"
} );
app.addMenuItem(
{
cName: "ShowBookmarks",
cUser: "转到指定书签(&T)",
cParent: "View",
cExec: "ShowBookmarks();",
cEnable: "event.rc= (event.target != null);"
} );
app.addMenuItem(
{
cName: "DropBookmark",
cUser: "删除一个书签(&D)",
cParent: "View",
cExec: "DropBookmark();",
cEnable: "event.rc= (event.target != null);"
} );
app.addMenuItem(
{
cName: "ClearBookmarks",
cUser: "删除所有书签(&C)",
cParent: "View",
cExec: "ClearBookmarks();",
cEnable: "event.rc= true;"
} );
4 将文件拷贝到C:\Program Files (x86)\Adobe\Reader
10.0\Reader\Javascripts目录下
5 重新打开Adobe Reader,看看下面的视图,相信不用说任何东西,大家都会用了
/yarctic/blog/item/4313f2f21e173a16b07ec538
正在阅读:
经典如何给PDF文件添加书签04-23
打印一份09-16
大二班作业单06-28
七年级09-10下学期语文期末复习试题09-12
北京市西城区2015-2016学年度第一学期七年级语文期末考试试卷09-07
光学公式09-29
对小学数学教学的回顾与思考03-06
2022年市应急管理局年度工作总结和下阶段工作规划及建议07-30
八年级政治下册《第一单元 第一课 第二框 我们享有广泛的权利》活动探究型教案2 新人教版10-08
乡镇上半年产业发展工作计划08-02
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- 书签
- 添加
- 文件
- 经典
- 如何
- (标准范文)大学生人际关系沟通存在的问题与对策
- 关于完善住房公积金管理制度的探讨
- 幼儿园民间体育游戏跳格子教案反思
- 00.投资逻辑及投资实务★★★★★
- 电动汽车充电负荷计算方法
- 2大学生职业生涯规划
- 自然资源学原理考试重点_张建松
- 建筑CAD中级试题0505
- 一年级口算练习题大全_适合一年级下学期孩子口算
- 2011年司法考试必考点民事诉讼的证据【必背】
- 2007年江苏省造价员考试土建案例试题解li
- 八年级英语上册英语课文原文
- 职场新人,面试技巧全攻略
- 学科带头人骨干教师培养计划
- 3新闻摄影的地位与功能
- PSL+603U系列线路保护技术说明书_1.20
- 服务行业员工服务礼仪及行为规范培训
- 2_软件项目合同管理
- 河北省二年级上学期语文期末质量检测试卷C卷
- 浅析自动喷水灭火系统的现状及将来的发展方向