Annotations gets shuffled on Copy / paste

I have used this method for copy selected annotations -


And this method for paste annotations -


But when I copy and paste multiple annotations like AnnotationCreateAreaMeasurement, AnnotationCreatePerimeterMeasurement, AnnotationCreateRubberStamp, rubber stamp always appears at last on paste when exportAnnotations() is called. It doesn’t paste as per the selection and copied annotations.

Like when I select and copy an area then a rubber stamp and then perimeter, and on paste rubber stand appears at last. (area,perimeter and then stamp). But I want it to be pasted exactly in the sequence as I select annotations.

Hi there!

I cannot reproduce your issue. What do you mean by “last”? Do you mean it appears visually under all the annotations, or just last in the exported XFDF?

If you could provide an example for us that would be very helpful.


Yes, it appears always last in the exported XFDF. But I want it to appear exactly how I select and copy in that sequence using updateCopiedAnnotations(); It should not get shuffled and appear at last.


XFDF elements are sorted by drawing order, so the way they are sorted in the XFDF is part of the PDF spec and is expected.

Closing this ticket as it is expected behaviour.