> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromiumly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Watermark and stamp

> Apply PDF-engine watermark and stamp overlays with PDFEngines.

`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

```typescript theme={null}
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 },
  },
});
```

On these two dedicated routes, `source` and `expression` are required — the SDK asserts both are set before sending the request. `downloadFrom`, `webhook`, `outputFilename`, and `trace` are also accepted (see [Request tracing](https://docs.chromiumly.dev/v6/advanced/request-tracing.md)); `downloadFrom` can fetch the watermark/stamp file itself remotely via `field: "watermark"` or `field: "stamp"`.

## Merge and split with overlays

```typescript theme={null}
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",
  },
});
```

Unlike the dedicated routes above, `source`/`expression` aren't required when `watermark`/`stamp` are used as optional post-processing on `merge()` and `split()`.

## Watermark/stamp payload shape

Use `PdfEngineWatermark` and `PdfEngineStamp`:

```typescript theme={null}
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`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.