用 JavaScript 的方式語法較簡單。
修改 UI
利用 app。如 app.addMenuItem
重要的參數包括:
- cName: The language-independent name of the menu item. This name can be used by other methods (for example, hideMenuItem) to access the menu item.
- cUser: (optional) The user string (language-dependent name) to display as the menu item name. If cUser is not specified, cName is used.
- cParent: The name of the parent menu item. Its submenu will have the new menu item added to it. If cParent has no submenu, an exception is thrown.
- Menu item names can be obtained with the listMenuItems method.
- nPos: (optional) The position within the submenu to locate the new menu item. The default behavior is to append to the end of the submenu. Specifying nPos as 0 adds the menu to the top of the submenu.
- The nPos parameter is ignored in certain menus that are alphabetized:
- cExec: An expression string to evaluate when the menu item is selected by the user.
quads 應用
quads 回傳的內容為 4 組 (x, y) 的座標內容。舉例來說,
quads: [[43],[756],[78],[756],[43],[745],[78],[745]],
代表的是如下圖的座標:
的座標。
下面是動態建立一個 quads 與 Annotation 的範例:
var quads1=this.getPageNthWordQuads(p, startIndex);
var quads2=this.getPageNthWordQuads(p, endIndex);
var quads=[[quads1[0][0], quads1[0][1], quads2[0][2], quads2[0][3], quads1[0][4], quads1[0][5], quads2[0][6], quads2[0][7]]];
var annot = this.addAnnot({page: p, type: "Highlight",
quads: quads, author: annotator
});
上面的程式碼要注意換行的情況。
沒有留言:
張貼留言