Skip to content

Conversation

@maximemenager
Copy link

This pull request introduces document watermarking feature using the pdfcpu library, enabling flexible watermark generation for PDF documents.

Implementation Notes:

  • Utilizes pdfcpu's native watermarking capabilities
  • Flexible parameter configuration
  • Supports multiple PDF document types
raclette raclette_approved raclette_text

@gulien gulien added enhancement New feature or request pdf-engines labels Nov 3, 2025
@maximemenager maximemenager force-pushed the FEAT-add-watermark-route branch from eb4aa37 to d9d8355 Compare November 3, 2025 14:05
Copy link
Collaborator

@gulien gulien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR!


Your current implementation is very linked to pdfcpu.

Other PDF engines may have a different implementation.

As a rule of thumb, new features related to PDF engines should have the correct abstraction so that implementations details do not leak in the API.


I think we should have a notion of stamp (in front of content) vs watermark (in the background).

Maybe two different routes?


When a new PDF engine functionality is added, it's also provided in the following endpoints:

  • /forms/chromium/convert/html
  • /forms/chromium/convert/url
  • /forms/chromium/convert/markdown
  • /forms/libreoffice/convert
  • /forms/pdfengines/merge
  • /forms/pdfengines/split

Don't forget to add the new flag pdfengines-watermark-engines in the Makefile.


Use a tag @watermark to tag your tests (see #1380).

// AddWatermark adds a watermark to a PDF file.
// The mode can be "text", "image", or "pdf".
// The watermark is either text content or a file path depending on the mode.
AddWatermark(ctx context.Context, logger *zap.Logger, mode, watermark, inputPath, description string) error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AddWatermark(ctx context.Context, logger *zap.Logger, mode, watermark, inputPath, description string) error
Watermark(ctx context.Context, logger *zap.Logger, mode, watermark, inputPath, description string) error

func watermarkRoute(engine gotenberg.PdfEngine) api.Route {
return api.Route{
Method: http.MethodPost,
Path: "/forms/pdfengines/add-watermark",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Path: "/forms/pdfengines/add-watermark",
Path: "/forms/pdfengines/watermark",

Comment on lines 646 to 651
var inputPaths []string
var watermarkPath string
var watermarkFilename string
var watermarkText string
var watermarkMode string
var params string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var inputPaths []string
var watermarkPath string
var watermarkFilename string
var watermarkText string
var watermarkMode string
var params string
var (
inputPaths []string
watermarkPath string
watermarkFilename string
watermarkText string
watermarkMode string
)

@tahaOABA tahaOABA force-pushed the FEAT-add-watermark-route branch from 4bd2939 to 58bbe64 Compare December 9, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pdf-engines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants