1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28: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:
Jonas Jenwald 2015-11-22 13:56:52 +01:00
parent aa75c4fe4e
commit b05652ca97
6 changed files with 55 additions and 17 deletions

View file

@ -400,8 +400,18 @@ describe('api', function() {
expect(viewport.height).toEqual(892.92);
});
it('gets annotations', function () {
var promise = page.getAnnotations();
waitsForPromiseResolved(promise, function (data) {
var defaultPromise = page.getAnnotations();
waitsForPromiseResolved(defaultPromise, function (data) {
expect(data.length).toEqual(4);
});
var displayPromise = page.getAnnotations({ intent: 'display' });
waitsForPromiseResolved(displayPromise, function (data) {
expect(data.length).toEqual(4);
});
var printPromise = page.getAnnotations({ intent: 'print' });
waitsForPromiseResolved(printPromise, function (data) {
expect(data.length).toEqual(4);
});
});