-
-
Notifications
You must be signed in to change notification settings - Fork 713
Add watermark for pdfengine #1379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add watermark for pdfengine #1379
Conversation
eb4aa37 to
d9d8355
Compare
gulien
left a comment
There was a problem hiding this 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).
pkg/gotenberg/pdfengine.go
Outdated
| // 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
pkg/modules/pdfengines/routes.go
Outdated
| func watermarkRoute(engine gotenberg.PdfEngine) api.Route { | ||
| return api.Route{ | ||
| Method: http.MethodPost, | ||
| Path: "/forms/pdfengines/add-watermark", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Path: "/forms/pdfengines/add-watermark", | |
| Path: "/forms/pdfengines/watermark", |
pkg/modules/pdfengines/routes.go
Outdated
| var inputPaths []string | ||
| var watermarkPath string | ||
| var watermarkFilename string | ||
| var watermarkText string | ||
| var watermarkMode string | ||
| var params string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 | |
| ) |
4bd2939 to
58bbe64
Compare
This pull request introduces document watermarking feature using the
pdfcpulibrary, enabling flexible watermark generation for PDF documents.Implementation Notes: