# Incorrect opacity for StampAnnotation on Chrome

**URL:** <https://pdfjs.community/t/incorrect-opacity-for-stampannotation-on-chrome/3036>\
**Category:** Bug Reports\
**Created:** [December 22, 2023, 3:10pm UTC](https://pdfjs.community/t/incorrect-opacity-for-stampannotation-on-chrome/3036 "2023-12-22T15:10:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorota.k](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dorota.k](https://pdfjs.community/u/dorota.k)\
**Post date:** [December 22, 2023, 3:10pm UTC](https://pdfjs.community/t/incorrect-opacity-for-stampannotation-on-chrome/3036/1 "2023-12-22T15:10:27Z")

</div>

**Which product are you using?**  
PDF.js Express Plus 8.7.4

**Detailed description of issue**  
Hi there!

Let’s try [this repo](https://github.com/pdfjs-express/pdfjs-express-react-sample) as our base, with upgrading library version to `8.7.4`.  
Let’s make some changes in code:

1. ‘/files/PDFTRON\_about.pdf’ - set correct file name in line 13
2. Add several stamps like below:

```javascript
        // add stamps
        for (let [x, y] of [[200, 500], [200, 550], [200, 600]]) {
          const stamp = new Annotations.StampAnnotation();
          stamp.PageNumber = 1;
          stamp.X = x;
          stamp.Y = y;
          stamp.Height = 20;
          stamp.Width = 20;
          stamp.setImageData('/goku.png');
          stamp.Opacity = 0.5;
          stamp.ReadOnly = true;
          annotManager.addAnnotation(stamp);
          // need to draw the annotation otherwise it won't show up until the page is refreshed
          annotManager.redrawAnnotation(stamp);
        }

```

In my real application I use svg file as a stamp, but it’s impossible to load that type of image here, that’s why I loaded here a sample as png (works the same for me, or rather doesn’t work):  
 ![goku](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/c/cfb6a47b18363e8fc29b9df60cc44a86601beea0.png)

Where is the problem? I set opacity as 0.5 and it applies on pdf very randomly (even with full opacity for all stamps) on Chrome (120.0.6099.129 - the same problem with previous version):  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/3/3f5fa3c6e9bffc99f2a538def5841f35faa4724f.png)  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/4/4171fd6b91a23cf2dc3169135843f7d69213864b.png)

Firefox looks much better for this sample - almost every page refreshing set correct opacity for all three stamps. Sometimes, after a change in code and refreshing page, one of the stamps is full, but it’s rather rare situation.

Any idea what I’m doing wrong?

Best regards and Merry Christmas 🎄,  
Dorota

---

<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:** [December 22, 2023, 10:13pm UTC](https://pdfjs.community/t/incorrect-opacity-for-stampannotation-on-chrome/3036/3 "2023-12-22T22:13:41Z")

</div>

Hello Dorota,

What you are doing is correct. I was able to reproduce this bug and I have added this to our backlog.

Best Regards and Merry Christmas 🎄,  
Darian

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [July 4, 2024, 5:14pm UTC](https://pdfjs.community/t/incorrect-opacity-for-stampannotation-on-chrome/3036/4 "2024-07-04T17:14:55Z")

</div>

Hello,

Apologies for the delay, you have to await setImageData so the API can get all the information before continuing to render.

```javascript
      await stamp.setImageData('/samples/viewing/viewing/logo.png');

```

Thank you  
Tyler

---

<div class="post-metadata">

**Author:** ![dorota.k](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dorota.k](https://pdfjs.community/u/dorota.k)\
**Post date:** [August 16, 2024, 1:54pm UTC](https://pdfjs.community/t/incorrect-opacity-for-stampannotation-on-chrome/3036/5 "2024-08-16T13:54:31Z")

</div>

Hello Tyler,

It helped in my case 👏

Thanks a lot,  
Dorota
