Skip to content

Commit

Permalink
updated for Annot tag, clear helper link objects, #293
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 committed Nov 1, 2024
1 parent 30cd175 commit ee0b902
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/org/metanorma/fop/annotations/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,25 @@ private void clearEmptyAnnotations(PDDocument document) throws IOException {
List<PDAnnotation> pageAnnotations = new ArrayList<>();
PDPage page = document.getPage(i);
for(PDAnnotation pageAnnotation: page.getAnnotations()) {
if(pageAnnotation.getContents() != null &&
!(pageAnnotation.getContents().startsWith(ANNOT_PREFIX))) {
boolean process = true;
if(pageAnnotation.getContents() != null && pageAnnotation.getContents().startsWith(ANNOT_PREFIX)) {
process = false;
}
// if link with alt-text Annot___ placed near the clause block, then the Contents changed to something like '1 Scope'
// therefore need remove links with small difference between coordinates
if (process) {
COSArray rect = pageAnnotation.getCOSObject().getCOSArray(COSName.RECT);
if (rect != null) {
float x1 = ((COSFloat)rect.get(0)).floatValue();
float x2 = ((COSFloat)rect.get(2)).floatValue();
if (x2 - x1 < 0.07f) {
process = false;
}
}
}

if (process) {
// clear Subject field with 'Annot___', see xfdf_simple.xsl, attribute 'subject'
String subj = pageAnnotation.getCOSObject().getString(COSName.SUBJ);
if (subj != null && subj.startsWith(ANNOT_PREFIX)) {
pageAnnotation.getCOSObject().setItem(COSName.SUBJ, null);
Expand Down

0 comments on commit ee0b902

Please sign in to comment.