PdfSigner
JVM/Desktop-only digital signing of PdfKmp (or any) PDF bytes.
Signing applies an incremental update to the input bytes — the original content is left untouched and a signature dictionary plus the appended CMS/PKCS#7 detached signature are added at the end. This is the standard way to keep a PDF signature valid (the signed byte range covers everything except the signature value itself).
Two entry points:
sign with a
(ByteArray) -> ByteArraycallback — no BouncyCastle dependency. The caller computes the CMS detached signature over the supplied byte range however they like (an HSM, a remote signing service, their own BC code) and returns the DER-encodedSignedData. This is the recommended path for production: PdfKmp never touches the private key.sign with a KeyStore / alias / password — a convenience that builds the CMS signature for you using BouncyCastle. BouncyCastle is a
compileOnlydependency of PdfKmp (the ~9 MB jar is not bundled into the published artifact), so callers using this overload must addorg.bouncycastle:bcpkix-jdk18onto their own runtime classpath. Calling it without BC on the classpath throws NoClassDefFoundError.
This is a JVM-only API and lives in jvmMain; there is no Android/iOS counterpart.
Functions
Signs pdfBytes using a caller-supplied CMS signing callback. No BouncyCastle dependency is involved on PdfKmp's side.