Transparent PNG Support

Illustration: Transparent PNG Support

Since 2020, our entire product line has supported PNG images with alpha transparency. This includes both simple transparency and semi-transparent masks for avoiding rough edges. Images with transparency (otherwise known as PNG alpha support) offer new possibilities for annotating documents across all platforms, and in this blog post, I want to show a couple examples of why this is useful.

Watermarks

It’s not unusual for people to add watermarks to documents before exporting them. While we always support text- and image-based watermarks, using PNG can be more convenient. For example, if you’re using your corporate logo, this ensures the font is exactly as specified.

Adding PNG-based watermarks can be done via our default UI or in code directly via our API. More specifically, this is accomplished by adding one image annotation to each page. Then, using flattening, the image is combined with the page so that it can no longer be removed.

Adding a Signature

Another great use case is adding a logo to your signature, as can be seen below in the form example for our Web product.

In this scenario, it’s important to preserve the transparency of the logo when adding it to the signature. Otherwise, it might obscure other important parts.

Conclusion

From the technical side of things, adding support for transparent PNG images to our SDK was a challenge, since the PDF format doesn’t support PNG files. Our workaround entails processing the image, removing the alpha layer, converting it into an SMask, and adding the result of all of this to the PDF as an XObject. However, these are all things you neither have to think about nor do, as our SDK takes care of them for you automatically!

All of our platforms now support adding PNGs with alpha transparency, which enables you to add improved workflows to your products. We’re excited to see what our partners will use this feature for.

PSPDFKit Newsletter

Subscribe to our newsletter for more articles like this.