{
  "name": "scorpiox-pdfwatermark",
  "version": "1.3.0",
  "exports": [
    {
      "name": "pdfwatermark_init",
      "return": "int",
      "csharp_return": "int",
      "args": [],
      "note": "Initialises the library subsystem. Returns 1."
    },
    {
      "name": "pdfwatermark_cleanup",
      "return": "void",
      "csharp_return": "void",
      "args": [],
      "note": "Releases library resources and clears the error buffer."
    },
    {
      "name": "pdfwatermark_text",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "input_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "output_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "text",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str",
          "note": "Watermark text string (e.g. CONFIDENTIAL)."
        },
        {
          "name": "opacity",
          "type": "float",
          "csharp_type": "float",
          "note": "Transparency 0.0 to 1.0 (e.g. 0.3)."
        },
        {
          "name": "rotation",
          "type": "float",
          "csharp_type": "float",
          "note": "Rotation angle in degrees."
        },
        {
          "name": "font_size",
          "type": "int",
          "csharp_type": "int",
          "note": "Font size in points (e.g. 48)."
        },
        {
          "name": "position",
          "type": "int",
          "csharp_type": "int",
          "note": "Position: 0=center, 1=top-left, 2=top-right, 3=bottom-left, 4=bottom-right, 5=diagonal."
        },
        {
          "name": "r",
          "type": "int",
          "csharp_type": "int",
          "note": "Red color component (0-255)."
        },
        {
          "name": "g",
          "type": "int",
          "csharp_type": "int",
          "note": "Green color component (0-255)."
        },
        {
          "name": "b",
          "type": "int",
          "csharp_type": "int",
          "note": "Blue color component (0-255)."
        }
      ],
      "note": "Adds text watermark to all pages of the PDF. Returns 1 on success, 0 on failure."
    },
    {
      "name": "pdfwatermark_image",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "input_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "output_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "image_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str",
          "note": "Path to PNG image file."
        },
        {
          "name": "opacity",
          "type": "float",
          "csharp_type": "float",
          "note": "Transparency 0.0 to 1.0."
        },
        {
          "name": "position",
          "type": "int",
          "csharp_type": "int",
          "note": "Position: 0=center, 1=top-left, 2=top-right, 3=bottom-left, 4=bottom-right, 5=diagonal/center."
        },
        {
          "name": "scale",
          "type": "float",
          "csharp_type": "float",
          "note": "Scaling factor (e.g. 1.0 = native size in points, 0.5 = 50%)."
        }
      ],
      "note": "Adds PNG image watermark to all pages of the PDF. Returns 1 on success, 0 on failure."
    },
    {
      "name": "pdfwatermark_text_range",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "input_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "output_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "text",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str",
          "note": "Watermark text string."
        },
        {
          "name": "opacity",
          "type": "float",
          "csharp_type": "float",
          "note": "Transparency 0.0 to 1.0."
        },
        {
          "name": "rotation",
          "type": "float",
          "csharp_type": "float",
          "note": "Rotation angle in degrees."
        },
        {
          "name": "font_size",
          "type": "int",
          "csharp_type": "int",
          "note": "Font size in points."
        },
        {
          "name": "position",
          "type": "int",
          "csharp_type": "int",
          "note": "Position: 0=center, 1=top-left, 2=top-right, 3=bottom-left, 4=bottom-right, 5=diagonal."
        },
        {
          "name": "r",
          "type": "int",
          "csharp_type": "int",
          "note": "Red color component (0-255)."
        },
        {
          "name": "g",
          "type": "int",
          "csharp_type": "int",
          "note": "Green color component (0-255)."
        },
        {
          "name": "b",
          "type": "int",
          "csharp_type": "int",
          "note": "Blue color component (0-255)."
        },
        {
          "name": "start_page",
          "type": "int",
          "csharp_type": "int",
          "note": "1-based start page index."
        },
        {
          "name": "end_page",
          "type": "int",
          "csharp_type": "int",
          "note": "1-based end page index (inclusive), or -1 for document end."
        }
      ],
      "note": "Adds text watermark to specific page range of the PDF. Returns 1 on success, 0 on failure."
    },
    {
      "name": "pdfwatermark_image_range",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "input_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "output_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "image_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str",
          "note": "Path to PNG image file."
        },
        {
          "name": "opacity",
          "type": "float",
          "csharp_type": "float",
          "note": "Transparency 0.0 to 1.0."
        },
        {
          "name": "position",
          "type": "int",
          "csharp_type": "int",
          "note": "Position: 0=center, 1=top-left, 2=top-right, 3=bottom-left, 4=bottom-right, 5=diagonal/center."
        },
        {
          "name": "scale",
          "type": "float",
          "csharp_type": "float",
          "note": "Scaling factor."
        },
        {
          "name": "start_page",
          "type": "int",
          "csharp_type": "int",
          "note": "1-based start page index."
        },
        {
          "name": "end_page",
          "type": "int",
          "csharp_type": "int",
          "note": "1-based end page index (inclusive), or -1 for document end."
        }
      ],
      "note": "Adds PNG image watermark to specific page range of the PDF. Returns 1 on success, 0 on failure."
    },
    {
      "name": "pdfwatermark_page_count",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "input_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "pages",
          "type": "int*",
          "csharp_type": "out int",
          "note": "Receives the true page count on success; left untouched on failure."
        }
      ],
      "note": "Returns the document's true page count parsed from the page tree (works for compressed object streams). Returns 1 on success, 0 on failure."
    },
    {
      "name": "pdfwatermark_last_error",
      "return": "const char*",
      "csharp_return": "string",
      "csharp_custom_marshal": "IntPtr + Marshal.PtrToStringAnsi",
      "args": [],
      "note": "Returns static buffer describing the last error, or empty string on success."
    },
    {
      "name": "pdfwatermark_set_layer",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "layer",
          "type": "int",
          "csharp_type": "int"
        }
      ],
      "note": "v1.1.3 export #9. 0 = over the page's own content (default, byte-identical to every release since 1.0.0); 1 = behind it (Acrobat's 'show watermark behind page content'). Sticky for the process; reset to 0 by init() and cleanup(). Returns 1 on accept, 0 on a bad value with last_error set. A page with no content of its own is unaffected."
    },
    {
      "name": "pdfwatermark_set_subset",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "kind",
          "type": "int",
          "csharp_type": "int"
        },
        {
          "name": "arg",
          "type": "int",
          "csharp_type": "int"
        }
      ],
      "note": "v1.1.4 export #10. Extra page filter applied on top of the inclusive start/end range. kind 0 = all pages (default, byte-identical to every release since 1.0.0); 1 = first N pages only (arg = N >= 1, clamped to the page count); 2 = odd pages only (1,3,5,...); 3 = even pages only (2,4,6,...). arg is ignored unless kind == 1 (pass 0). Sticky for the process; reset to 0 by init() and cleanup(). Returns 1 on accept, 0 on a bad kind or a kind-1 arg < 1 with last_error set (the previous subset stays in force). An empty subset (even-only on a 1-page document) is refused by the work exports: rc 0, last_error names the page count, no output file written."
    },
    {
      "name": "pdfwatermark_set_cancel_flag",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "flag",
          "type": "int *",
          "csharp_type": "IntPtr",
          "note": "Pinned caller-owned int. IntPtr.Zero clears it (\"no cancel\", also accepted)."
        }
      ],
      "note": "v1.2.0 export #11. Register a caller-owned 32-bit int the engine polls while it works. The engine only READS it, so the caller keeps it alive and pinned for the whole job (GCHandle.Alloc(int[1], Pinned)). Polled in five places: after the document parse, every 1 MiB of the byte scan inside doc_load(), at the top of every page-loop iteration (text and image), inside the writer's per-object emit loops, and immediately before the finished file is renamed into place. On a cancel the work export returns 0, sets last_error to \"cancelled by user\", removes its temporary file and writes NO output file. Sticky process-global like set_layer/set_subset; reset to NULL by init() and cleanup(). Returns 1 on accept. Deliberately does NOT touch last_error (it is called from a UI thread while a job may be running on another)."
    },
    {
      "name": "pdfwatermark_progress",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "pages_done",
          "type": "int *",
          "csharp_type": "out int / IntPtr (may be NULL)"
        },
        {
          "name": "pages_total",
          "type": "int *",
          "csharp_type": "out int / IntPtr (may be NULL)"
        }
      ],
      "note": "v1.2.0 export #12. Publishes the current (or most recent) job's counters. pages_total is the FILTERED page count \u2014 the number the range+subset pair actually selects (19 on an odd-only run of a 38-page document), not doc.pages.n. Before the first job both read 0; during a job they climb; after a job the final values stay until the next job starts. Safe to poll from another thread (a UI timer). Returns 1 on success; 0 with last_error set only when BOTH pointers are NULL. Never touches last_error on the success path."
    },
    {
      "name": "pdfwatermark_remove",
      "return": "int",
      "csharp_return": "int",
      "args": [
        {
          "name": "input_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str"
        },
        {
          "name": "output_path",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str",
          "note": "NULL = scan only: nothing is written, the count is still returned."
        },
        {
          "name": "text",
          "type": "const char*",
          "csharp_type": "string",
          "marshal": "UnmanagedType.LPUTF8Str",
          "note": "NULL or \"\" = Mode A (exact: remove the marks this engine wrote). Non-empty = Mode B (best effort: also remove a BT\u2026ET block whose shown string equals this text)."
        },
        {
          "name": "marks_removed",
          "type": "int *",
          "csharp_type": "out int / IntPtr (may be NULL)",
          "note": "Receives the number of marks removed (dropped /SxWm content streams plus Mode-B text blocks)."
        }
      ],
      "note": "v1.3.0 export #13. Removes watermarks from a PDF. Mode A (text NULL/empty) removes the marks THIS ENGINE wrote: every stamping path emits a mark as its own content-stream object wrapped in q\u2026Q around a /SxWmGS gs operator (text: BT\u2026/SxWmF<n>\u2026Tj ET, image: /SxWmIm Do), so a /Contents entry is a mark iff its stream BODY carries that shape. Body-based, never resource-name-based (a resource-name test false-positives on a stale /ExtGState /SxWmGS entry). The companion 'q' stream of the wrapped form is dropped and the now-unreferenced /SxWm* resource entries are stripped. Mode B additionally removes a BT\u2026ET block whose shown string equals text \u2014 (literal) Tj, [(a)(b)] TJ and <hex> Tj are decoded and compared; surrounding whitespace is ignored on both sides but the comparison is otherwise exact. NOT covered by design: OCG / optional-content watermark layers, annotations and stamps, and marks whose glyphs are drawn as vector paths. NEVER describe this export as 'removes any watermark'. output_path == NULL means scan only. Nothing matched \u21d2 rc 0, last_error names 0, NO output file. rc == 1 \u21d2 last_error == \"\". Cancel-aware and progress-aware (done = pages cleaned, total = page count)."
    }
  ]
}
