为Adobe reader 9.5.1添加书签功能
来源:互联网 发布:mysql union 是什么 编辑:程序博客网 时间:2024/05/22 10:40
步骤:
1、将下文中的代码保存为:bookmark_page.js
2、保存完毕后,将bookmark_page.js复制到C:\Program Files\Adobe\Reader 9.0\Reader\Javascripts(即为adobe reader的安装目录路径)
3、启动adobe reader ,如下图所示:
代码为:
// bookmark_page.js, ver. 1.0
// visit: www.pdfhacks.com/bookmark_page/
// use this delimiter for serializing our array
var bp_delim= '%#%#';
function SaveData( data ) {
// data is an array of arrays that needs
// to be serialized and stored into a persistent
// global string
var ds= '';
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 );
}
function GetData() {
// 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;
}
function AddBookmark() {
// query the user for a name, and then combine it with
// the current PDF page to create a record; store this record
var label=
app.response( "书签名称:",
"书签名称",
"",
false );
if( label!= null ) {
var record= new Array(3);
record[0]= label;
record[1]= this.path;
record[2]= this.pageNum;
data= GetData();
data.push( record );
SaveData( data );
}
}
function ShowBookmarks() {
// 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 FirstPage NextPage calls
//
app.openDoc( data[index][1] );
app.execMenuItem( "FirstPage" );
for( ii= 0; ii< data[index][2]; ++ii ) {
app.execMenuItem( "NextPage" );
}
}
catch( ee ) {
var response=
app.alert("打开请求的标签出现错误.\n需要该删除这个书签吗?", 2, 2);
if( response== 4 && index< data.length ) {
data.splice( index, 1 );
SaveData( data );
}
}
}
}
function DropBookmark() {
// 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 );
}
}
function ClearBookmarks() {
if( app.alert("你确定你想要删除所有的书签吗?", 2, 2 )== 4 ) {
SaveData( new Array(0) );
}
}
app.addMenuItem( {
cName: "-", // menu divider
cParent: "View", // append to the View menu
cExec: "void(0);" } );
app.addMenuItem( {
cName: "添加标签",
cParent: "View",
cExec: "AddBookmark();",
cEnable: "event.rc= (event.target != null);" } );
app.addMenuItem( {
cName: "选择一个标签",
cParent: "View",
cExec: "ShowBookmarks();",
cEnable: "event.rc= (event.target != null);" } );
app.addMenuItem( {
cName: "移除一个标签",
cParent: "View",
cExec: "DropBookmark();",
cEnable: "event.rc= (event.target != null);" } );
app.addMenuItem( {
cName: "清除所有标签",
cParent: "View",
cExec: "ClearBookmarks();",
cEnable: "event.rc= true;" } );
- 为Adobe reader 9.5.1添加书签功能
- 为Adobe reader添加书签功能
- 为Adobe Reader添加书签功能
- 使用Javascript为Adobe Reader X 添加书签功能
- 给Adobe Reader添加书签功能
- 给Adobe Reader添加书签功能
- 在Adobe Reader里添加书签功能
- adobe reader pdf 添加书签功能
- 如何向adobe reader添加书签功能
- Adobe Reader 下添加书签功能
- 给Adobe Reader添加书签功能
- Adobe Reader 11.0添加书签功能
- 为pdf阅读器(adobe reader)添加书签
- adobe reader添加书签
- adobe reader 怎么添加书签
- 在Adobe Reader中加入书签功能
- adobe reader x 10增加书签功能
- adobe reader x增加书签功能
- 2003服务器,禁止CMD新建用户
- 面试中常见链表问题8:重排链表
- jquery之setTimeout(简单拉幕广告示例)
- IE6出现重复字符(文字溢出)的bug
- jQuery判断是否是隐藏标签
- 为Adobe reader 9.5.1添加书签功能
- ELK之Elasticsearch介绍及在搜索中的使用
- 找到栈最小元素
- Linux shell快速查找PHP木马
- HttpClient 发送 HTTP、HTTPS 请求的简单封装
- 清除 Linux 登陆信息及日志
- nginx配置fastdfs插件后无法访问
- poj1321
- windows系统利用IIS实现网站服务网络负载均衡