/** * Copyright (c) 2006-2008 John Ford, released under the MIT license * pdf_bookmark.js - http://www.aldenta.com/ * http://www.aldenta.com/2006/09/15/plugin-bookmark-a-page-in-your-pdf/ * Inspired by http://www.pdfhacks.com/bookmark_page/ * * Similar to a physical book and bookmark, this plugin lets you bookmark * the page you're on and return to that single page later. * * 1.2 - Nov 30, 2008 - Use documentFileName on PDFs that don't have a docID * Add French translation (TitCouille) * Add installation paths for Linux (TitCouille) * 1.1 - Dec 20, 2007 - Update to work with Adobe Reader 8 due to security changes (app.trustedFunction) * 1.0 - Sep 15, 2006 - Initial release * * Installation: * * Adobe Reader 9 - copy this file to: * Mac: ~/Library/Application Support/Adobe/Acrobat/9.0_x86/JavaScripts (or similar) * Linux: /home/[User Name]/.adobe/Acrobat/9.0/JavaScripts/ * Windows: C:\Documents and Settings\[User Name]\Application Data\Adobe\Acrobat\9.0\JavaScripts (or similar) * * Adobe Reader 8 - copy this file to: * Mac: ~/Library/Acrobat User Data/8.0_x86/JavaScripts (or similar) * Linux: /home/[User Name]/.adobe/Acrobat/8.0/JavaScripts/ * Windows: C:\Documents and Settings\[User Name]\Application Data\Adobe\Acrobat\8.0\JavaScripts (or similar) * * Adobe Reader 7 - copy this file to: * Mac: ~/Library/Acrobat User Data/7.0/JavaScripts (or similar) * Linux: /home/[User Name]/.adobe/Acrobat/7.0/JavaScripts/ * Windows: C:\Documents and Settings\[User Name]\Application Data\Adobe\Acrobat\7.0\JavaScripts (or similar) * * Note: you may have to create the JavaScripts folder * * Open Adobe Reader and access the menu by going to Tools -> Bookmarks. * Sometimes it may take a minute to load the menu so just give it a second and then click on Tools again. * * Tested with Adobe Reader 7 and 8 on Mac and Windows */ var DELIM = '%#%#'; var DEBUG = false; /** * Add a bookmark for this page. Only one bookmark will be kept per document */ function addBookmark() { var id = (this.docID && this.docID[0] && this.docID[0] != '') ? this.docID[0] : this.documentFileName; if (id != null) { data = getData(); data[id] = this.pageNum; saveData(data); } } /** * Go to the bookmarked page for this document if one exists */ function gotoBookmark() { var data = getData(); var id = (this.docID && this.docID[0] && this.docID[0] != '') ? this.docID[0] : this.documentFileName; for (var n in data) { if (id == n) { this.pageNum = data[n]; return; } } } /** * Loads the bookmarks from the glob.js */ function getData() { if ( getPDFBookmark() == null ) { return {}; } var flat = getPDFBookmark().split( DELIM ); var data = {}; for (i=0; i