This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/public/pdfjs/controllers/annotationlayer_controller.js

60 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-04-21 20:37:42 +00:00
PDFJS.Reader.AnnotationLayerController = function (options, reader) {
this.reader = reader;
this.annotationDiv = options.annotationDiv;
this.pdfPage = options.pdfPage;
this.renderInteractiveForms = options.renderInteractiveForms;
this.linkService = options.linkService;
this.downloadManager = options.downloadManager;
this.div = null;
return this;
};
PDFJS.Reader.AnnotationLayerController.prototype.render = function (viewport, intent) {
var self = this;
var parameters = {
intent: (intent === undefined ? 'display' : intent),
};
this.pdfPage.getAnnotations(parameters).then(function (annotations) {
viewport = viewport.clone({ dontFlip: true });
parameters = {
viewport: viewport,
div: self.div,
annotations: annotations,
page: self.pdfPage,
renderInteractiveForms: self.renderInteractiveForms,
linkService: self.linkService,
downloadManager: self.downloadManager,
};
if (self.div) {
// If an annotationLayer already exists, refresh its children's
// transformation matrices.
PDFJS.AnnotationLayer.update(parameters);
} else {
// Create an annotation layer div and render the annotations
// if there is at least one annotation.
if (annotations.length === 0) {
return;
}
self.div = self.annotationDiv;
parameters.div = self.div;
PDFJS.AnnotationLayer.render(parameters);
}
});
};
PDFJS.Reader.AnnotationLayerController.prototype.hide = function () {
if (!this.div) {
return;
}
this.div.setAttribute('hidden', 'true');
};