|
|
@ -27,8 +27,6 @@ |
|
|
|
* @class |
|
|
|
* @class |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() { |
|
|
|
var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() { |
|
|
|
var CustomStyle = PDFJS.CustomStyle; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param {AnnotationsLayerBuilderOptions} options |
|
|
|
* @param {AnnotationsLayerBuilderOptions} options |
|
|
|
* @constructs AnnotationsLayerBuilder |
|
|
|
* @constructs AnnotationsLayerBuilder |
|
|
@ -56,22 +54,14 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() { |
|
|
|
|
|
|
|
|
|
|
|
this.pdfPage.getAnnotations(parameters).then(function (annotations) { |
|
|
|
this.pdfPage.getAnnotations(parameters).then(function (annotations) { |
|
|
|
viewport = viewport.clone({ dontFlip: true }); |
|
|
|
viewport = viewport.clone({ dontFlip: true }); |
|
|
|
var data, element, i, ii; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self.div) { |
|
|
|
if (self.div) { |
|
|
|
// If an annotationLayer already exists, refresh its children's
|
|
|
|
// If an annotationLayer already exists, refresh its children's
|
|
|
|
// transformation matrices.
|
|
|
|
// transformation matrices.
|
|
|
|
for (i = 0, ii = annotations.length; i < ii; i++) { |
|
|
|
PDFJS.AnnotationLayer.update(viewport, self.div, annotations); |
|
|
|
data = annotations[i]; |
|
|
|
|
|
|
|
element = self.div.querySelector( |
|
|
|
|
|
|
|
'[data-annotation-id="' + data.id + '"]'); |
|
|
|
|
|
|
|
if (element) { |
|
|
|
|
|
|
|
CustomStyle.setProp('transform', element, |
|
|
|
|
|
|
|
'matrix(' + viewport.transform.join(',') + ')'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.div.removeAttribute('hidden'); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// Create an annotation layer div and render the annotations
|
|
|
|
|
|
|
|
// if there is at least one annotation.
|
|
|
|
if (annotations.length === 0) { |
|
|
|
if (annotations.length === 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -80,19 +70,10 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() { |
|
|
|
self.div.className = 'annotationLayer'; |
|
|
|
self.div.className = 'annotationLayer'; |
|
|
|
self.pageDiv.appendChild(self.div); |
|
|
|
self.pageDiv.appendChild(self.div); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0, ii = annotations.length; i < ii; i++) { |
|
|
|
PDFJS.AnnotationLayer.render(viewport, self.div, annotations, |
|
|
|
data = annotations[i]; |
|
|
|
self.pdfPage, self.linkService); |
|
|
|
if (!data || !data.hasHtml) { |
|
|
|
if (typeof mozL10n !== 'undefined') { |
|
|
|
continue; |
|
|
|
mozL10n.translate(self.div); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
element = PDFJS.AnnotationLayer.getHtmlElement(data, self.pdfPage, |
|
|
|
|
|
|
|
viewport, |
|
|
|
|
|
|
|
self.linkService); |
|
|
|
|
|
|
|
if (typeof mozL10n !== 'undefined') { |
|
|
|
|
|
|
|
mozL10n.translate(element); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.div.appendChild(element); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|