Configure PDF watermarks and stamps
mainYou can apply watermarks or stamps to PDFs using the watermark and stamp options. These use the same multipart field names as Gotenberg's PDF-engine. You can provide text, an image, or a PDF as the source. When using an image or PDF, you must provide the file property.
Supported source values:
text: Use theexpressionproperty for the text content.image: Use theexpressionproperty for the filename of the uploaded asset and provide thefile(Buffer or Stream).pdf: Use theexpressionproperty for the filename of the uploaded asset and provide thefile(Buffer or Stream).
Common properties:
pages: Page ranges (e.g.,"1-3"). Omit for all pages.options: Engine-specific JSON configuration (e.g., forpdfcpu).
type PdfEngineWatermark = {
source?: 'text' | 'image' | 'pdf';
expression?: string; // Text, or filename of the uploaded asset when source is image or pdf
pages?: string; // Page ranges (e.g. "1-3"); omit for all pages
options?: Record<string, unknown>; // Serialized as JSON (engine-specific)
file?: PathLikeOrReadStream | Buffer; // Required when source is image or pdf
};
type PdfEngineStamp = {
source?: 'text' | 'image' | 'pdf';
expression?: string;
pages?: string;
options?: Record<string, unknown>;
file?: PathLikeOrReadStream | Buffer;
};