# Change position a button textpopup

**URL:** <https://pdfjs.community/t/change-position-a-button-textpopup/2836>\
**Category:** Technical Support\
**Created:** [September 11, 2023, 2:03am UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836 "2023-09-11T02:03:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![duongxuanhieu1999](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/duongxuanhieu1999/32/1550_2.png) [@duongxuanhieu1999](https://pdfjs.community/u/duongxuanhieu1999)\
**Post date:** [September 11, 2023, 2:03am UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836/1 "2023-09-11T02:03:29Z")

</div>

**Which product are you using?**  
PDF.js Express Viewer

**PDF.js Express Version**  
8.7.4

**Detailed description of issue**  
Hi, i use code below to add a button in textpopup, is there anyway to change this button position in pdf viewer

**Expected behaviour**  
{Provide a screenshot or description of the expected behaviour}

**Does your issue happen with every document, or just one?**  
{Answer here}

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**

```javascript
this.webViewerInstance.textPopup.add({
                type: 'actionButton',
                onClick: () => {
                    this.onClickHandler()
                },
                img: '/img/mrc/table-file.svg'
            })

```

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [September 11, 2023, 4:27pm UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836/2 "2023-09-11T16:27:26Z")

</div>

Hello there,

You change the order of the text popup buttons using the following code:

```javascript
  let textPopupItems = instance.UI.textPopup.getItems()

  const printButton =
  {
    type: 'actionButton',
    onClick: () => {
      this.onClickHandler()
    },
    img: 'icon-header-print-line'
  }

  textPopupItems.splice(2, 0, printButton);
  instance.UI.textPopup.update(textPopupItems);

```

Note I am using a printButton as an example. I inserted the new button at index 2 of the array.

Let me know if this helps.

Best Regards,  
Darian Chen

---

<div class="post-metadata">

**Author:** ![duongxuanhieu1999](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/duongxuanhieu1999/32/1550_2.png) [@duongxuanhieu1999](https://pdfjs.community/u/duongxuanhieu1999)\
**Post date:** [September 12, 2023, 1:26am UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836/3 "2023-09-12T01:26:14Z")

</div>

Hi darian.chen, i mean change the location of button textpopup in viewer by a specific coordinate not the order

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [September 12, 2023, 1:40pm UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836/4 "2023-09-12T13:40:52Z")

</div>

Hello there,

Could you clarify where you want the button to be with a screenshot?

Best Regards,  
Darian Chen

---

<div class="post-metadata">

**Author:** ![duongxuanhieu1999](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/duongxuanhieu1999/32/1550_2.png) [@duongxuanhieu1999](https://pdfjs.community/u/duongxuanhieu1999)\
**Post date:** [September 13, 2023, 8:21am UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836/5 "2023-09-13T08:21:23Z")

</div>

current, the position of textpopup is center and below textselected, i want to position is right after textselected

 ![Screenshot from 2023-09-13 15-15-22](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/a/affe65ec8368970a69093593d790713cca8a53cb.jpeg)

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [September 13, 2023, 1:56pm UTC](https://pdfjs.community/t/change-position-a-button-textpopup/2836/6 "2023-09-13T13:56:01Z")

</div>

Hello,

Unfortunately, there are no settings/APIs to change the textPopup position in PDF.js Express. In order to do this, you would have to fork our public repo and then make any customizations you want directly in the source.

[Here is a guide on that](https://pdfjs.express/documentation/ui-customization/advanced-customization).

From there, the changes would likely have to be made in the getPopupPosition helper file here:

> <https://github.com/PDFTron/webviewer-ui/blob/646daecae50d54b3ddc0531652f027bf0c6a139e/src/helpers/getPopupPosition.js#L16C2-L20C5>

Best Regards,  
Darian Chen
