Добавить кликабельную аннотацию штампа PSPDFKit
Я использую PSPDFKit для работы с PDF-файлами. Суть моей заявки - добавить штамп в PDF, который отлично работает. Но я хотел бы сделать свои штампы кликабельными, чтобы я мог щелкнуть по ним из другого средства просмотра PDF (например, Acrobat).
У меня есть много способов сделать это, но единственное правдоподобное - сделать мои штампы кликабельными.
Я добавляю штамп благодаря пользовательскому интерфейсу PSPDFKit, но я реализую свою собственную логику для обработки создания аннотаций.
pdfDocument.getAnnotationProvider().addOnAnnotationUpdatedListener(new AnnotationProvider.OnAnnotationUpdatedListener(){
//I check if this is the first Stamp annotation I created for this session.
//If it isn't I just move the previous one to the new point
//Each time I open my PDF I can add only one stamp annotation
@Override
public void onAnnotationCreated(@NonNull com.pspdfkit.annotations.Annotation annotation) {
if(annotation instanceof StampAnnotation){
if(currentAnnotation != null){
if(fragment.getDocument() != null) {
fragment.getDocument().getAnnotationProvider().removeAnnotationFromPage(annotation);
fragment.notifyAnnotationHasChanged(annotation);
}
}
else{
((StampAnnotation) annotation).setSubtext(currentImageName);
currentAnnotation = annotation;
}
/*
Trying to find how to make currentAnnotation a clickable annotation
I used the subtext attribute to store some data relevant for my action.
I also looked up for LinkAnnotations but I can't figure how they work out
*/
}
}
//I check if the annotation is a Stamp.
//If it is, I add it to annotations to remove from my app's business logic
@Override
public void onAnnotationRemoved(@NonNull com.pspdfkit.annotations.Annotation annotation) {
if(annotation instanceof StampAnnotation){
runOnUiThread(() ->Toast.makeText(PSPdfFloorPlanActivity.this, "Annotation removed " + ((StampAnnotation) annotation).getSubtext(), Toast.LENGTH_SHORT).show());
if(annotation.equals(currentAnnotation)){
currentAnnotation = null;
}
removedAnnotationsImagesNames.add(((StampAnnotation) annotation).getSubtext());
}
}
});
Спасибо заранее, если вопрос кажется широким комментарием, который я пытаюсь сделать, как можно проще понять ^^
Сердечно, Матье