Skip to content

Commit

Permalink
removing temp empty links, #293
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 committed Oct 31, 2024
1 parent b1e32c1 commit 17de40a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/metanorma/fop/annotations/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ public void process(File pdf, String xmlReview) throws IOException {
HashMap<String,PDAnnotation> hashMapDocumentAnnotations = new HashMap<>();
hashMapDocumentAnnotations = getAnnotationIDmap(document);


clearEmptyAnnotations(document);

document.save(pdf);

} catch (IOException | NumberFormatException | ParserConfigurationException | DOMException | TransformerException | SAXException | XPathException ex) {
Expand Down Expand Up @@ -333,4 +336,18 @@ private HashMap<String,PDAnnotation> getAnnotationIDmap(PDDocument document) thr
return hashMapDocumentAnnotations;
}

private void clearEmptyAnnotations(PDDocument document) throws IOException {
for (int i = 0; i < document.getNumberOfPages(); i++)
{
List<PDAnnotation> pageAnnotations = new ArrayList<>();
PDPage page = document.getPage(i);
for(PDAnnotation pageAnnotation: page.getAnnotations()) {
if(!(pageAnnotation.getContents().startsWith("Annot___"))) {
pageAnnotations.add(pageAnnotation);
}
}
document.getPage(i).setAnnotations(pageAnnotations);
}
}

}

0 comments on commit 17de40a

Please sign in to comment.