# Annotations gets shuffled on Copy / paste

**URL:** https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255
**Category:** Technical Support
**Tags:** pdfjs-express
**Created:** [September 14, 2020, 8:24am UTC](https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255 "2020-09-14T08:24:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kiran.patil](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kiran.patil](https://pdfjs.community/u/kiran.patil)
#### Post date: [September 14, 2020, 8:24am UTC](https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255/1 "2020-09-14T08:24:55Z")

</div>

I have used this method for copy selected annotations -

> ```
> this.viewerInstance.annotManager.updateCopiedAnnotations();
> 
> ```

And this method for paste annotations -

> ```
> this.viewerInstance.annotManager.pasteCopiedAnnotations();
> 
> ```

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.

---

<div class="post-metadata">

### Author: ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)
#### Post date: [September 15, 2020, 2:22pm UTC](https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255/2 "2020-09-15T14:22:59Z")

</div>

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.

Thanks,  
Logan

---

<div class="post-metadata">

### Author: ![kiran.patil](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kiran.patil](https://pdfjs.community/u/kiran.patil)
#### Post date: [September 16, 2020, 1:05pm UTC](https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255/3 "2020-09-16T13:05:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)
#### Post date: [September 16, 2020, 5:28pm UTC](https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255/4 "2020-09-16T17:28:06Z")

</div>

Hi,

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.

Thanks!  
Logan

---

<div class="post-metadata">

### Author: ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)
#### Post date: [September 16, 2020, 5:28pm UTC](https://pdfjs.community/t/annotations-gets-shuffled-on-copy-paste/255/5 "2020-09-16T17:28:09Z")

</div>


