mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 07:38:07 +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
|
@ -45,9 +45,10 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
|
|||
|
||||
/**
|
||||
* @param {PageViewport} viewport
|
||||
* @param {string} intent (default value is 'display')
|
||||
*/
|
||||
setupAnnotations:
|
||||
function AnnotationsLayerBuilder_setupAnnotations(viewport) {
|
||||
function AnnotationsLayerBuilder_setupAnnotations(viewport, intent) {
|
||||
function bindLink(link, dest) {
|
||||
link.href = linkService.getDestinationHash(dest);
|
||||
link.onclick = function annotationsLayerBuilderLinksOnclick() {
|
||||
|
@ -73,8 +74,12 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
|
|||
var linkService = this.linkService;
|
||||
var pdfPage = this.pdfPage;
|
||||
var self = this;
|
||||
var getAnnotationsParams = {
|
||||
intent: (intent === undefined ? 'display' : intent),
|
||||
};
|
||||
|
||||
pdfPage.getAnnotations().then(function (annotationsData) {
|
||||
pdfPage.getAnnotations(getAnnotationsParams).then(
|
||||
function (annotationsData) {
|
||||
viewport = viewport.clone({ dontFlip: true });
|
||||
var transform = viewport.transform;
|
||||
var transformStr = 'matrix(' + transform.join(',') + ')';
|
||||
|
|
|
@ -275,7 +275,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
}
|
||||
|
||||
if (redrawAnnotations && this.annotationLayer) {
|
||||
this.annotationLayer.setupAnnotations(this.viewport);
|
||||
this.annotationLayer.setupAnnotations(this.viewport, 'display');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -507,7 +507,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
this.annotationLayer = this.annotationsLayerFactory.
|
||||
createAnnotationsLayerBuilder(div, this.pdfPage);
|
||||
}
|
||||
this.annotationLayer.setupAnnotations(this.viewport);
|
||||
this.annotationLayer.setupAnnotations(this.viewport, 'display');
|
||||
}
|
||||
div.setAttribute('data-loaded', true);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue