HI,
i’m working with Aspsose latesr version 23.8, and when I try to remove links from PDFs that were created with Winword 365 I get null in goToURIAction for link
and when I open the output file in Acrobat Reader, the link still remain where I’m wrong or how can I remove the link complete?
this is my code:
private void neutralizeAnnotationURIAction(CleaningResponse response, CleanOptions ops, GoToURIAction action) {
if (action != null) {
logger.finer("Found a non-null action. Removing.");
action.setURI(" ");
}else {
logger.warrning("NUll action reciveed.");
}
}
private void handleAnnotations(Document doc, CleaningResponse response, CleanOptions ops) {
doc.setOpenAction(null);
for (Page page: doc.getPages()) {
AnnotationCollection Annotations= page.getAnnotations();
for (Annotation annot :Annotations ) {
try {
switch (annot.getAnnotationType()) {
case Link:
LinkAnnotation la = (annot instanceof LinkAnnotation ? (LinkAnnotation) annot : null);
logger.finer("Found LinkAnnotation in document.");
try {
GoToURIAction goToURIAction = (GoToURIAction) la.getAction();
neutralizeAnnotationURIAction(response, ops, goToURIAction);
}catch (Exception e)
{
logger.warrning("Failed parsing link Annot reason + " + e.getMessage());
Annotations.remove(annot);
}
}
break;
case RichMedia:
logger.finer("Found RichMediaAnnotation in document.");
//do something
break;
case Movie:
logger.finer("Found MovieAnnotation in document.");
//do something
break;
case Sound:
logger.finer("Found SoundAnnotation in document.");
//do something
break;
case Screen:
logger.finer("Found ScreenAnnotation in document.");
//do something
break;
case FileAttachment:
logger.finer("Found FileAttachment in documnet");
//do something
}
}catch (Exception e) {
logger.warrning("exception in Annotation due to reason " + e.getMessage());
}
}
}
}
}
test.7z (34.5 KB)