// Copyright (c) 2026 Probo Inc . // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY // AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR // OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. package esign import ( "bytes" "fmt" "github.com/pdfcpu/pdfcpu/pkg/api" "github.com/pdfcpu/pdfcpu/pkg/pdfcpu/types" ) func StampSignatureID(pdfData []byte, signatureID string) ([]byte, error) { text := fmt.Sprintf("Electronic Signature ID: %s", signatureID) desc := "fontname:Helvetica, points:9, pos:tl, rot:0, op:1.0, scale:1.0 abs, color:0.3 0.3 0.3, offset:10 -10" wm, err := api.TextWatermark(text, desc, true, false, types.POINTS) if err != nil { return nil, fmt.Errorf("cannot create signature ID stamp: %w", err) } reader := bytes.NewReader(pdfData) var buf bytes.Buffer if err := api.AddWatermarks(reader, &buf, nil, wm, nil); err != nil { return nil, fmt.Errorf("cannot stamp signature ID on PDF: %w", err) } return buf.Bytes(), nil }