API referenceCore SDK

pdfDeleteWatermark

Tag a template (Form XObject) as a watermark so PDF editors

C
BOOL32 __stdcall pdfMarkTemplateAsWatermark(PPDF IPDF, uint32_t Handle);
int32_t __stdcall pdfDeleteWatermark(PPDF IPDF, int32_t PageNum, BOOL32 InclAnnots);
Delphi
function pdfMarkTemplateAsWatermark(const IPDF: PPDF; Handle: Cardinal): LongBool; stdcall;
function pdfDeleteWatermark(const IPDF: PPDF; PageNum: Integer; InclAnnots: LongBool): Integer; stdcall;

Purpose. Tag a template (Form XObject) as a watermark so PDF editors recognize it as such, and delete watermarks from one page or the whole document.

Description. pdfMarkTemplateAsWatermark attaches the standard /PieceInfo /ADBE_CompoundType marker (/Private /Watermark) to the template's Form XObject — the same convention Adobe Acrobat's watermark tool uses, so marked templates can be identified and removed by common PDF editors. It works for drawn templates (pdfBeginTemplate) and imported-page templates alike.

pdfDeleteWatermark removes marked watermark templates: their placement operators and resource entries are stripped from the affected pages (PageNum = -1 for the entire document, which also deletes the form objects themselves). Both templates marked in this session and imported forms already carrying the ADBE_CompoundType watermark marker are recognized. If InclAnnots is true, Watermark annotations (pdfWatermarkAnnot) are deleted too (they do not increment the return value).

Parameters.

ParameterDescription
IPDFDocument handle.
HandleTemplate handle from pdfBeginTemplate/import.
PageNum1-based page, or -1 for all pages.
InclAnnotsAlso delete Watermark annotations.

Return value. pdfMarkTemplateAsWatermark: True on success. pdfDeleteWatermark: the number of deleted watermarks, or a negative value on error.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfDeleteWatermark(IntPtr IPDF, int PageNum, [MarshalAs(UnmanagedType.Bool)] bool InclAnnots);
Area
Core SDK
Category

Core

Exported names

pdfDeleteWatermark

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.