-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathPDFJSAnnotate.js
95 lines (82 loc) · 2.31 KB
/
PDFJSAnnotate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import StoreAdapter from './adapter/StoreAdapter';
import LocalStoreAdapter from './adapter/LocalStoreAdapter';
import LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';
import render from './render';
import UI from './UI';
import config from './config';
import uuid from './utils/uuid';
import {
findAnnotationAtPoint,
findSVGContainer,
convertToScreenPoint
} from './UI/utils';
export default {
findAnnotationAtPoint,
findSVGContainer,
convertToScreenPoint,
/**
* Abstract class that needs to be defined so PDFJSAnnotate
* knows how to communicate with your server.
*/
StoreAdapter,
/**
* Implementation of StoreAdapter that stores annotation data to localStorage.
*/
LocalStoreAdapter,
/**
* Implementation of StoreAdapter that stores annotation data to localStorage particular
* to a specific user
*/
LocalUserStoreAdapter,
/**
* Abstract instance of StoreAdapter
*/
__storeAdapter: new StoreAdapter(),
/**
* Getter for the underlying StoreAdapter property
*
* @return {StoreAdapter}
*/
getStoreAdapter() {
return this.__storeAdapter;
},
/**
* Setter for the underlying StoreAdapter property
*
* @param {StoreAdapter} adapter The StoreAdapter implementation to be used.
*/
setStoreAdapter(adapter) {
// TODO this throws an error when bundled
// if (!(adapter instanceof StoreAdapter)) {
// throw new Error('adapter must be an instance of StoreAdapter');
// }
this.__storeAdapter = adapter;
},
/**
* UI is a helper for instrumenting UI interactions for creating,
* editing, and deleting annotations in the browser.
*/
UI,
/**
* Render the annotations for a page in the PDF Document
*
* @param {SVGElement} svg The SVG element that annotations should be rendered to
* @param {PageViewport} viewport The PDFPage.getViewport data
* @param {Object} data The StoreAdapter.getAnnotations data
* @return {Promise}
*/
render,
/**
* Convenience method for getting annotation data
*
* @alias StoreAdapter.getAnnotations
* @param {String} documentId The ID of the document
* @param {String} pageNumber The page number
* @return {Promise}
*/
getAnnotations(documentId, pageNumber) {
return this.getStoreAdapter().getAnnotations(...arguments);
},
config,
uuid
};