Skip to main content
PDFEngines supports watermark and stamp in three ways:
  • PDFEngines.watermark() for /forms/pdfengines/watermark.
  • PDFEngines.stamp() for /forms/pdfengines/stamp.
  • Optional watermark / stamp on PDFEngines.merge() and PDFEngines.split().
Watermark is rendered behind page content. Stamp is rendered on top of page content.

Dedicated routes

import { PDFEngines } from "chromiumly";

const watermarked = await PDFEngines.watermark({
  files: ["path/to/document.pdf"],
  watermark: {
    source: "text",
    expression: "CONFIDENTIAL",
    options: { opacity: 0.25, rotation: 45 },
  },
});

const stamped = await PDFEngines.stamp({
  files: ["path/to/document.pdf"],
  stamp: {
    source: "text",
    expression: "APPROVED",
    options: { opacity: 0.5, rotation: 0 },
  },
});

Merge and split with overlays

import { PDFEngines } from "chromiumly";

const merged = await PDFEngines.merge({
  files: ["path/to/1.pdf", "path/to/2.pdf"],
  watermark: {
    source: "text",
    expression: "INTERNAL",
  },
});

const split = await PDFEngines.split({
  files: ["path/to/combined.pdf"],
  options: { mode: "pages", span: "1-3" },
  stamp: {
    source: "text",
    expression: "PAGE_COPY",
  },
});

Watermark/stamp payload shape

Use PdfEngineWatermark and PdfEngineStamp:
type PdfEngineWatermark = {
  source?: "text" | "image" | "pdf";
  expression?: string;
  pages?: string;
  options?: Record<string, unknown>;
  file?: PathLikeOrReadStream | Buffer;
};

type PdfEngineStamp = {
  source?: "text" | "image" | "pdf";
  expression?: string;
  pages?: string;
  options?: Record<string, unknown>;
  file?: PathLikeOrReadStream | Buffer;
};
For source: "image" or source: "pdf", set expression to the uploaded filename and provide the asset in file.