1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Render Popup annotations last, once all other annotations have been rendered (issue 11362)

In the current `AnnotationLayer` implementation, Popup annotations require that the parent annotation have already been rendered (otherwise they're simply ignored).
Usually the annotations are ordered, in the `/Annots` array, in such a way that this isn't a problem, however there's obviously no guarantee that all PDF generators actually do so. Hence we simply ensure, when rendering the `AnnotationLayer`, that the Popup annotations are handled last.
This commit is contained in:
Jonas Jenwald 2020-01-25 16:53:34 +01:00
parent 3775b711ed
commit 62b2b984cc
4 changed files with 236 additions and 0 deletions

View file

@ -1417,10 +1417,26 @@ class AnnotationLayer {
* @memberof AnnotationLayer
*/
static render(parameters) {
const sortedAnnotations = [],
popupAnnotations = [];
// Ensure that Popup annotations are handled last, since they're dependant
// upon the parent annotation having already been rendered (please refer to
// the `PopupAnnotationElement.render` method); fixes issue 11362.
for (const data of parameters.annotations) {
if (!data) {
continue;
}
if (data.annotationType === AnnotationType.POPUP) {
popupAnnotations.push(data);
continue;
}
sortedAnnotations.push(data);
}
if (popupAnnotations.length) {
sortedAnnotations.push(...popupAnnotations);
}
for (const data of sortedAnnotations) {
const element = AnnotationElementFactory.create({
data,
layer: parameters.div,