Docs / Get started

Markdown

Get started with C and other languages

One C library for C, C++, Python (ctypes), Go, Java, Swift and anything else that can call C.

Files

  • uds_pdf.h: the header.
  • libuds_pdf.dylib / .so, uds_pdf.dll, or the static libuds_pdf.a.

Rules of the API

  • UdsDocument* handles are opaque; free them with uds_document_free().
  • Results come back as UdsBuffer*: read them with uds_buffer_data() and uds_buffer_len(), free them with uds_buffer_free(). Text is UTF-8 and NUL-terminated.
  • Errors return -1 or NULL; uds_last_error() describes the last error on the calling thread.
  • Annotations and settings are passed as JSON strings, the same JSON as in JavaScript and .NET.

Example

#include <stdio.h>#include "uds_pdf.h" int main(void) {    UdsDocument *doc = uds_document_open(data, len, NULL);   /* NULL: no password */    if (!doc) { fprintf(stderr, "%s\n", uds_last_error()); return 1; }    printf("%d pages\n", uds_document_page_count(doc));     uds_annotation_add_json(doc, 0, "{\"type\":\"Stamp\",\"rect\":[320,80,520,140],\"icon\":\"Final\"}");     UdsBuffer *out = uds_document_save(doc, 0);              /* 1 = incremental */    fwrite(uds_buffer_data(out), 1, uds_buffer_len(out), stdout);    uds_buffer_free(out);    uds_document_free(doc);    return 0;}
clang example.c -Iinclude -Llib -luds_pdf -Wl,-rpath,@loader_path/lib -o example

The full list of functions is in the C API reference.