Zig
Zig
PDF List Unsigned Signature Fields
See more PDF Signatures Examples
Demonstrates how to list the unsigned signature fields in a PDF.Note: This example requires Chilkat v9.5.0.90 or greater.
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const pdf = try chilkat.Pdf.init();
defer pdf.deinit();
// Load a PDF containing 2 remaining unsigned signature fields:
pdf.loadFile("qa_data/pdf/doctor_patient_parent.pdf") catch {
std.debug.print("{s}\n", .{try pdf.getLastErrorText(alloc)});
return;
};
// Note: This example requires Chilkat v9.5.0.90 or greater.
const json = try chilkat.JsonObject.init();
defer json.deinit();
pdf.getUnsignedSigFields(json) catch {};
json.setEmitCompact(false);
std.debug.print("{s}\n", .{try json.emit(alloc)});
// Result:
// {
// "unsignedSigField": [
// "doctor_signature",
// "parent_signature"
// ]
// }
// To iterate over the field names:
var str_val: [:0]const u8 = "";
var i: i32 = 0;
const count_i = json.sizeOfArray("unsignedSigField");
while (i < count_i) {
json.setI(i);
str_val = try json.stringOf(alloc, "unsignedSigField[i]");
std.debug.print("{s}\n", .{str_val});
i = i + 1;
}
}