mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
[api-minor] Let getAnnotations
fetch all annotations by default, unless an intent is specified
Currently `getAnnotations` will *only* fetch annotations that are either `viewable` or `printable`. This is "hidden" inside the `core.js` file, meaning that API consumers might be confused as to why they are not recieving *all* the annotations present for a page. I thus think that the API should, by default, return *all* available annotations unless specifically told otherwise. In e.g. the default viewer, we obviously only want to display annotations that are `viewable`, hence this patch adds an `intent` parameter to `getAnnotations` that makes it possible to decide if only `viewable` or `printable` annotations should be fetched.
This commit is contained in:
parent
aa75c4fe4e
commit
b05652ca97
6 changed files with 55 additions and 17 deletions
|
@ -252,10 +252,16 @@ var Page = (function PageClosure() {
|
|||
});
|
||||
},
|
||||
|
||||
getAnnotationsData: function Page_getAnnotationsData() {
|
||||
getAnnotationsData: function Page_getAnnotationsData(intent) {
|
||||
var annotations = this.annotations;
|
||||
var annotationsData = [];
|
||||
for (var i = 0, n = annotations.length; i < n; ++i) {
|
||||
if (intent) {
|
||||
if (!(intent === 'display' && annotations[i].viewable) &&
|
||||
!(intent === 'print' && annotations[i].printable)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
annotationsData.push(annotations[i].data);
|
||||
}
|
||||
return annotationsData;
|
||||
|
@ -268,7 +274,7 @@ var Page = (function PageClosure() {
|
|||
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
||||
var annotationRef = annotationRefs[i];
|
||||
var annotation = annotationFactory.create(this.xref, annotationRef);
|
||||
if (annotation && (annotation.viewable || annotation.printable)) {
|
||||
if (annotation) {
|
||||
annotations.push(annotation);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue