We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose pdf java - Cannot update AnnotationType

Hi Aspose,

I’d like to update AnnotationType for example: from HighlightAnnotation to StrikeOutAnnotation annotation
I have been searching for this feature but I am not lucky with it.

My idea for the moment is delete the old annotation and create new one, but I think that’s not a very good solution.

Is there any solution for my problem ? I hope that, I can get some support for this.

Thank you very much
Best regards
Sy Le

Hi Sy Le,

Thanks for contacting support.

Currently you can extract annotations from PDF file and add them back after modifications. I am afraid that you cannot update/change the type of the annotation, instead you can delete the old one after grabbing its parameters/values to create/add new, as you said.

However, I have logged a feature request with ticket ID PDFJAVA-36775 in our issue tracking system, for the sake of enhancement. We will further look into details of the feature and keep you updated on the status of resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

Best Regards,

Hi Sy Le,

Thanks for your patience.

Development team has further investigated your requirement and shared their feedback. The annotations are too different and created by different ways, using different input data and they cannot be simply changed into each others. However, you can use following code to change all the HighlightAnnotations to StrikeOutAnnotations with with the same rectangle.

Document doc = new Document(dataDir + “Annotations.pdf”);
Page page = doc.getPages().get_Item(1);

for (int i = 1; i <= page.getAnnotations().size(); i++)
com.aspose.pdf.Annotation annot = (com.aspose.pdf.Annotation) page.getAnnotations().get_Item(i);
if (annot.getAnnotationType() == AnnotationType.Highlight)
System.out.println(“Changing Annotation Type…”);
com.aspose.pdf.Annotation annot2 = new StrikeOutAnnotation(page, annot.getRect());
break; //this line will cause the exit from cycle after the first Highlight annotation found.

doc.save(dataDir + “SwitchedAnnotation.pdf”);

In case of any further assistance, please feel free to contact us.

Best Regards,

Hi Asad Ali
Thank you for your information. So we have no better way to change it for the moment. So I will keep my first solution in our product.

Thank you

Best Regards

Hi Sy Le,

Thanks for your feedback.

Please keep using our API and in case you have any further query, please feel free to ask.

Best Regards,