1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Merge pull request #6675 from Snuffleupagus/getAnnotations-intent

[api-minor] Let `getAnnotations` fetch all annotations by default, unless an intent is specified
This commit is contained in:
Yury Delendik 2015-11-24 12:11:51 -06:00
commit 4b243cdd89
6 changed files with 55 additions and 17 deletions

View file

@ -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);
}
}

View file

@ -399,7 +399,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
handler.on('GetDestination',
function wphSetupGetDestination(data) {
return pdfManager.ensureCatalog('getDestination', [ data.id ]);
return pdfManager.ensureCatalog('getDestination', [data.id]);
}
);
@ -447,7 +447,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
return pdfManager.getPage(data.pageIndex).then(function(page) {
return pdfManager.ensure(page, 'getAnnotationsData', []);
return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
});
});