PaperForge.Signature (PaperForge v1.4.2)

Copy Markdown View Source

Adds and verifies provider-backed digital signatures.

The default provider signs incrementally with PAdES and PKCS#8 PEM material using Elixir/OTP only. Select another provider per call with :provider or configure one globally with config :paper_forge, :signature_provider.

{:ok, signed_pdf} =
  PaperForge.Signature.sign(pdf,
    certificate: {:pkcs8, key_path: "key.pem", cert_path: "cert.pem"},
    reason: "Contract approval",
    location: "Monterrey, Mexico"
  )

Passwords and private keys are call-time values and are never stored in a declarative template or compiled-template cache.

Summary

Functions

Returns the capabilities advertised by the selected provider.

Signs a PDF binary without rewriting its original revision.

Signs a PDF binary and raises when the provider rejects the operation.

Signs an existing PDF and writes the signed revision to destination.

Verifies a signed PDF with the selected provider and trust policy.

Types

result()

@type result() :: {:ok, binary()} | {:error, term()}

Functions

capabilities(options \\ [])

@spec capabilities(keyword()) :: [PaperForge.Signature.Provider.capability()]

Returns the capabilities advertised by the selected provider.

sign(pdf, options)

@spec sign(
  binary(),
  keyword()
) :: result()

Signs a PDF binary without rewriting its original revision.

sign!(pdf, options)

@spec sign!(
  binary(),
  keyword()
) :: binary()

Signs a PDF binary and raises when the provider rejects the operation.

sign_file(source, destination, options \\ [])

@spec sign_file(Path.t(), Path.t(), keyword()) :: :ok | {:error, term()}

Signs an existing PDF and writes the signed revision to destination.

verify(pdf, options \\ [])

@spec verify(
  binary(),
  keyword()
) :: {:ok, term()} | {:error, term()}

Verifies a signed PDF with the selected provider and trust policy.