pdfDeleteWatermark
Tag a template (Form XObject) as a watermark so PDF editors
BOOL32 __stdcall pdfMarkTemplateAsWatermark(PPDF IPDF, uint32_t Handle);
int32_t __stdcall pdfDeleteWatermark(PPDF IPDF, int32_t PageNum, BOOL32 InclAnnots);
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.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Handle | Template handle from pdfBeginTemplate/import. |
PageNum | 1-based page, or -1 for all pages. |
InclAnnots | Also delete Watermark annotations. |
Return value. pdfMarkTemplateAsWatermark: True on success. pdfDeleteWatermark: the number of deleted watermarks, or a negative value on error.
C# (P/Invoke)
public static extern int pdfDeleteWatermark(IntPtr IPDF, int PageNum, [MarshalAs(UnmanagedType.Bool)] bool InclAnnots);
Core
pdfDeleteWatermark
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.