Skip to content

Commit

Permalink
GH-140 FIxes missing popups (#141)
Browse files Browse the repository at this point in the history
* Fixes conflict with PropertiesManager renaming

* GH-140 Checks for missing popup annotations when initing page annotations

* GH-140 Checks for null popup
  • Loading branch information
gtache committed Sep 23, 2020
1 parent 7550457 commit 6373168
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/core-awt/src/main/java/org/icepdf/core/pobjects/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.FreeTextAnnotation;
import org.icepdf.core.pobjects.annotations.MarkupAnnotation;
import org.icepdf.core.pobjects.annotations.PopupAnnotation;
import org.icepdf.core.pobjects.graphics.Shapes;
import org.icepdf.core.pobjects.graphics.WatermarkCallback;
import org.icepdf.core.pobjects.graphics.text.GlyphText;
Expand All @@ -34,10 +35,8 @@
import java.awt.geom.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.*;
import java.util.List;
import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -359,6 +358,18 @@ else if (annotObj instanceof HashMap) { // HashMap lacks "Type"->"Annot" entry
a != null ? " " + a.getPObjectReference() + a.getEntries() : "");
}
}
//The popup annotations may not be referenced in the page annotations entry, we have to add them manually.
final Set<Annotation> annotSet = new HashSet<>(annotations);
for (final Annotation annot : annotSet) {
if (annot instanceof MarkupAnnotation) {
final PopupAnnotation popup = ((MarkupAnnotation) annot).getPopupAnnotation();
if (popup != null && !annotSet.contains(popup)) {
popup.init();
v.add(popup);
annotations.add(popup);
}
}
}
}
}

Expand Down

0 comments on commit 6373168

Please sign in to comment.