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

@@ -53,19 +53,36 @@ Feature: /forms/pdfengines/stamp
# Repeating the stamp fields applies several stamps in one request, in order.
# Image and pdf stamps consume the uploaded stamp files in order; text stamps
# take none. See https://github.com/gotenberg/gotenberg/pull/1601.
# take none. Both text stamps must land, so their content is asserted (the
# options keep them unrotated and apart so pdftotext reads them cleanly).
# See https://github.com/gotenberg/gotenberg/pull/1601.
Scenario: POST /forms/pdfengines/stamp (Multiple Stamps - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_STAMP_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/stamp" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| stampSource | text | field |
| stampExpression | CONFIDENTIAL | field |
| stampSource | image | field |
| stamp | testdata/watermark.png | file |
| files | testdata/page_1.pdf | file |
| stampSource | text | field |
| stampExpression | STAMPONE | field |
| stampOptions | {"rotation":"0","position":"tl","scale":"0.2 abs"} | field |
| stampSource | text | field |
| stampExpression | STAMPTWO | field |
| stampOptions | {"rotation":"0","position":"br","scale":"0.2 abs"} | field |
| stampSource | image | field |
| stamp | testdata/watermark.png | file |
| Gotenberg-Output-Filename | foo | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| foo.pdf |
Then the "foo.pdf" PDF should have the following content at page 1:
"""
STAMPONE
"""
Then the "foo.pdf" PDF should have the following content at page 1:
"""
STAMPTWO
"""
Scenario: POST /forms/pdfengines/stamp (PDF - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):

View File

@@ -51,6 +51,39 @@ Feature: /forms/pdfengines/watermark
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
# Repeating the watermark fields applies several watermarks in one request, in
# order. Image and pdf watermarks consume the uploaded watermark files in
# order; text watermarks take none. Both text watermarks must land, so their
# content is asserted (the options keep them unrotated and apart so pdftotext
# reads them cleanly).
Scenario: POST /forms/pdfengines/watermark (Multiple Watermarks - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_WATERMARK_ENGINES | pdfcpu |
When I make a "POST" request to Gotenberg at the "/forms/pdfengines/watermark" endpoint with the following form data and header(s):
| files | testdata/page_1.pdf | file |
| watermarkSource | text | field |
| watermarkExpression | MARKONE | field |
| watermarkOptions | {"rotation":"0","position":"tl","scale":"0.2 abs"} | field |
| watermarkSource | text | field |
| watermarkExpression | MARKTWO | field |
| watermarkOptions | {"rotation":"0","position":"br","scale":"0.2 abs"} | field |
| watermarkSource | image | field |
| watermark | testdata/watermark.png | file |
| Gotenberg-Output-Filename | foo | header |
Then the response status code should be 200
Then the response header "Content-Type" should be "application/pdf"
Then there should be 1 PDF(s) in the response
Then there should be the following file(s) in the response:
| foo.pdf |
Then the "foo.pdf" PDF should have the following content at page 1:
"""
MARKONE
"""
Then the "foo.pdf" PDF should have the following content at page 1:
"""
MARKTWO
"""
Scenario: POST /forms/pdfengines/watermark (PDF - pdfcpu)
Given I have a Gotenberg container with the following environment variable(s):
| PDFENGINES_WATERMARK_ENGINES | pdfcpu |