feat(pdfengines): apply multiple stamps and watermarks on every route

This commit is contained in:
Julien Neuhart
2026-08-14 16:36:40 +02:00
parent e9a67132ec
commit 3de6932279
8 changed files with 302 additions and 248 deletions

View File

@@ -156,3 +156,26 @@ func TestBindStampFiles(t *testing.T) {
})
}
}
func TestFormDataPdfWatermarks(t *testing.T) {
ctx := &api.ContextMock{Context: &api.Context{}}
ctx.SetValues(map[string][]string{
"watermarkSource": {"text", "image"},
"watermarkExpression": {"DRAFT"},
"watermarkOptions": {`{"opacity":"0.5"}`, ""},
})
form := ctx.FormData()
got, err := FormDataPdfWatermarks(form)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
want := []gotenberg.Stamp{
{Source: "text", Expression: "DRAFT", Options: map[string]string{"opacity": "0.5"}},
{Source: "image"},
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("watermarks = %#v, want %#v", got, want)
}
}