# Create image stamp annotations getting internal server error

**URL:** <https://pdfjs.community/t/create-image-stamp-annotations-getting-internal-server-error/115>\
**Category:** Technical Support\
**Created:** [July 7, 2020, 5:03am UTC](https://pdfjs.community/t/create-image-stamp-annotations-getting-internal-server-error/115 "2020-07-07T05:03:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jithinkp](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jithinkp](https://pdfjs.community/u/jithinkp)\
**Post date:** [July 7, 2020, 5:03am UTC](https://pdfjs.community/t/create-image-stamp-annotations-getting-internal-server-error/115/1 "2020-07-07T05:03:39Z")

</div>

I want to add image stamp for 6 pages of pdf in a single click.I tried below method to add stamp but i got “Internal server error”.

```
instance.setHeaderItems(function(header) {
            header.push({
                type: 'actionButton',
                img: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m0 0h24v24h-24z" fill="none"></path><path d="m21 19v-14c0-1.1-.9-2-2-2h-14c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zm-12.5-5.5 2.5 3.01 3.5-4.51 4.5 6h-14z"></path></svg>',
                onClick: function() {

                    var pages=docViewer.Pq.length;
                    onSavetwo();
                    async function onSavetwo() {

                        for (i = 1; i <= pages; i++) {
                            var stampAnnot = new Annotations.StampAnnotation();
                            stampAnnot.PageNumber = i;
                            stampAnnot.X = 100;
                            stampAnnot.Y = 250;
                            stampAnnot.Width = 275;
                            stampAnnot.Height = 40;
                            stampAnnot.ImageData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB.....';
                            stampAnnot.Author = await annotManager.getCurrentUser();

                            annotManager.addAnnotation(stampAnnot);
                            annotManager.redrawAnnotation(stampAnnot);
                        }

                    }

                }
            });
        });

```

 ![Annotation 2020-07-07 103123](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ff415bd3396c7d3234d3dffb2bc78db70c9a5d27.png)

The below pdf i have used

[pdf](https://wetransfer.com/downloads/93069331bcf43e2f741698b240a134e920200707050805/0f9013644d27982da8fab73672aa485920200707050823/15cb39)

I have tried first two pages image stamp annotations it is working morethan 3 page pdf getting this error.Please help.

---

<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:** [July 7, 2020, 2:28pm UTC](https://pdfjs.community/t/create-image-stamp-annotations-getting-internal-server-error/115/2 "2020-07-07T14:28:57Z")

</div>

Hi!

I don’t think the code you sent is what’s causing that error. The code you sent makes no requests to the API. Can you please confirm you sent the correct code snippet?

Also PS, I’m not sure where you found that `docViewer.Pq.length` code, but the best way to get the number of pages is this:

```javascript
const pages = docViewer.getDocument().getPageCount()

```

Thank you,  
Logan
