pdfcpu / pdfcpu

A PDF processor written in Go.
http://pdfcpu.io/
Apache License 2.0
6.48k stars 457 forks source link

Bug with black background when RGBA image is stamped on PDF #894

Closed toshi1127 closed 2 days ago

toshi1127 commented 1 week ago

description

When an image with a transparent background is added to a PDF, such as favicon.png below, the background turns black. (In the case of RGBA)

favicon

スクリーンショット 2024-06-21 11 30 35

example code

func StampImage(inFile string, outFile string, selectedPages []string, fileName string) error {
    config := model.NewDefaultConfiguration()
    desc := "pos: tl, off: 0 0, scale: 1 a, rot:0, mode:1"
    onTop := true
    wm, err := pdfcpu.ParseImageWatermarkDetails(fileName, desc, onTop, types.POINTS)
    if err != nil {
        return err
    }
    return api.AddWatermarksFile(inFile, outFile, selectedPages, wm, config)
}

environment

macOS Ventura 13.0 pdfcpu https://github.com/pdfcpu/pdfcpu/commit/576f15e6cd191b62168d7b26879ab3b1133b29bc