PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
This guide applies to ComPDF Android SDK 3.2.1. Start by checking where the private key is stored:
.p12 or .pfx file containing the certificate and its private key, along with the file password.For two-phase signing, check what the service returns. A complete CMS container includes the signature value and certificates, so the SDK can embed it as-is. A raw signature value contains only the signature bytes. Provide the certificates separately so the SDK can build the CMS container. These two paths support different algorithms. For supported Android versions, see System Requirements.
| Signature Algorithm | Local Signing | Two-Phase: Complete CMS | Two-Phase: Raw Signature | SDK Validation |
|---|---|---|---|---|
| RSA-PKCS#1 v1.5 (RSA-2048, RSA-3072) | ✅ Supported | ✅ Supported | ✅ Supported | ✅ Supported |
ECDSA P-256 (including SHA256withECDSA) | ✅ Supported | ✅ Supported | ✅ Supported (DER encoding) | ✅ Supported |
| ECDSA P-384 | ✅ Supported (SHA-256) | ✅ Supported | ✅ Supported (DER encoding) | ✅ Supported |
| RSA-PSS | ❌ Not supported | ✅ Can embed | ❌ Not supported | ⚠️ Limited support; see below |
Raw ECDSA signatures: Pass the signature value as a DER-encoded SEQUENCE { r, s }. If the service returns a fixed-length r‖s value (IEEE P1363), convert it to DER before embedding it in the PDF. This conversion applies to the signature value, not the certificate.
RSA-PSS: Have the signing service return a complete CMS container, not a raw signature value. The SDK can embed the container, but validation depends on the public key type in the signing certificate. SDK validation support is limited to RSASSA-PSS public keys. With a standard RSA public key (rsaEncryption), the SDK may report integrity.failed even if it embedded the container successfully. Before integrating RSA-PSS, validate the output PDF with the certificates and signing parameters you plan to use.
If you need a certificate for testing, use generatePKCS12Cert() in Create Digital Certificates to generate an RSA-2048 test certificate. For local ECDSA signing, provide a PKCS#12 file that contains the ECDSA certificate and its matching private key.
A digest is a short digital fingerprint of the data to be signed. SHA-256, SHA-384, and SHA-512 compute that fingerprint; RSA and ECDSA are used to sign. For two-phase signing, configure the SDK and your signing service to use the same digest algorithm.
| Digest Algorithm | Local Signing Output | Two-Phase: Complete CMS | Two-Phase: Raw Signature | RFC 3161 Timestamp Request |
|---|---|---|---|---|
| SHA-256 | ✅ Supported | ✅ Supported | ✅ Supported | ✅ Supported |
| SHA-384 | — | ✅ Supported | ✅ Supported | — |
| SHA-512 | — | ✅ Supported | ✅ Supported | — |
A dash (—) means the algorithm is not listed as supported for that workflow. The two-phase columns apply to RSA-PKCS#1 v1.5, ECDSA P-256, and ECDSA P-384. RSA-PSS has the limitations described above. The timestamp request column shows which digest the SDK sends to the timestamp authority, not which algorithm the authority uses to sign the returned timestamp.
| Use Case | Supported Format | What to Provide |
|---|---|---|
| Local signing | PKCS#12 (.p12, .pfx) | Give writeSignature() the path to the file containing the signing certificate and its private key, along with the file password. |
| Embed a complete CMS container | Detached CMS/PKCS#7 container | Have the signing service include the signer certificate and any required intermediate certificates. Pass the complete container to fillWithContainer(). |
| Embed a raw signature value | DER-encoded X.509 signer certificate; DER bytes for each certificate in the chain | When preparing the signature, pass the signer certificate to setSignerCertificateDer(). If you need to supply a chain, pass the DER bytes for each certificate to setCertificateChainDer(). Convert PEM certificates to DER first. |
| Validate the certificate chain | Trusted root certificates in PEM format | Set the path to the trusted roots with setTrustedCertPath(). If you have a DER certificate or a .p7b container, export the required root certificate as PEM first. |
Validate the signed PDF after embedding the signature. Successful embedding only confirms that the signature was written. Before delivering the PDF, validate the output to check both the integrity of the signed content and whether the signing certificate is trusted.