PdfSigner

class PdfSigner(doc: PdfDocument, editor: PdfEditor, placeholderSize: Int = 16 * 1024)

Digital signature SCAFFOLD (T-84): the prepare-then-sign flow that stages a signature field, computes the exact /ByteRange, and embeds a caller-supplied CMS blob. The library does NO cryptography: the DER SignedData comes from the application (JVM apps can build one with java.security; that is their code, not ours).

val editor = doc.edit()
val signer = PdfSigner(doc, editor)
signer.prepareSignature("Signature1")
val target = signer.saveForSigning()
val cms = myPkcs7Detached(target.bytes, target.byteRange) // app-side crypto
val signed = PdfSigner.embedSignature(target.bytes, target.byteRange, cms)

Constructors

Link copied to clipboard
constructor(doc: PdfDocument, editor: PdfEditor, placeholderSize: Int = 16 * 1024)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class SigningTarget(val bytes: ByteArray, val byteRange: IntArray)

The signed bytes plus the exact /ByteRange the CMS must cover.

Functions

Link copied to clipboard
fun prepareSignature(fieldName: String, rect: Rectangle? = null, pageIndex: Int = 0)

Stage the signature machinery: a /Sig value dict with the /Contents placeholder and a fixed-width /ByteRange placeholder, a merged field+widget on page pageIndex (invisible when rect is null), and the AcroForm wiring (/SigFlags 3).

Link copied to clipboard

Serialize incrementally, locate the /Contents placeholder, patch the /ByteRange in place (space-padded to the reserved width so no offset moves), and return the bytes plus the range: [0, start] and [end, size-end] cover the whole file except the hex string itself.