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.
Long-term validation (LTV) uses certificates and revocation information stored in a document for later verification. ComPDF provides document-level material assessment, PAdES signing, and material augmentation for signed documents.
CPDFLtvService.assessReadiness(document) inspects DSS (Document Security Store) and VRI (Validation Related Information) materials in the open document, including unsaved in-memory state. Run this operation on a background thread.
import com.compdfkit.core.signature.CPDFLtvService;
import com.compdfkit.core.signature.CPDFLtvReadinessResult;
import com.compdfkit.core.signature.CPDFLtvReadinessInfo;
CPDFLtvReadinessResult result = CPDFLtvService.assessReadiness(document);
if (result != null && result.isSuccess()) {
CPDFLtvReadinessInfo info = result.getReadinessInfo();
if (info != null) {
boolean ready = info.isLtvReady();
String[] missingMaterials = info.getMissingMaterials();
// Display readiness and missing materials.
}
} else {
// Check that the document is open and inspect errors and warnings if result is non-null.
}| Method | Purpose |
|---|---|
hasDss(), hasVri() | Check for DSS and VRI |
hasCertificates(), hasRevocation() | Check for certificate and OCSP/CRL materials |
isLtvReady(), getMissingMaterials() | Read readiness and missing materials |
getDssInfo() | Read DSS material counts and related information |
getErrors(), getWarnings() | Read errors and warnings from the assessment result |
Material readiness does not establish certificate trust, validate revocation evidence, or prove that all signatures meet PAdES-LT. For validation, see Verify Digital Signatures and enable setCheckRevocation(true).
CPDFPadesSigner.sign() creates a signature field and appearance from CPDFPadesOptions and generates the files required by the selected profile.
Profile | Output stage | Required output paths |
|---|---|---|
B | Basic signature | signedPath |
T | Signature timestamp | signedPath |
LT | Adds long-term validation materials | signedPath, ltvPath |
LTA | Also adds a document timestamp | signedPath, ltvPath, ltaPath |
Save all content before calling the method. It reloads the file and excludes unsaved in-memory edits. Output paths must differ from one another and from the source path; create their directories first. Run network operations on a background thread and configure android.permission.INTERNET.
This example creates an invisible LT signature. trustedCertPath is a trusted root PEM bundle or OpenSSL-style certificate directory, and tsaUrl is an accessible TSA address:
import com.compdfkit.core.signature.CPDFPadesOptions;
import com.compdfkit.core.signature.CPDFPadesResult;
import com.compdfkit.core.signature.CPDFPadesSigner;
CPDFPadesOptions options = new CPDFPadesOptions()
.setProfile(CPDFPadesOptions.Profile.LT)
.setCertificate(certificatePath, certificatePassword)
.setFieldName("ApprovalSignature")
.setVisible(false)
.setTsaUrl(tsaUrl)
.setTrustedCertPath(trustedCertPath);
CPDFPadesResult result = CPDFPadesSigner.sign(
sourcePath, signedPath, ltvPath, null, options);
if (result != null && result.isSuccess()) {
String finalPath = result.getFinalPath();
// Use the file from the final stage.
} else {
// Inspect getErrors() and getWarnings() if result is non-null.
}For a visible signature, use setField(pageIndex, rect) and configure the appearance. The field name must be unique. sign() creates its own field; it neither signs an existing field nor sets a DocMDP certification reference. For those cases, use writeSignature() and then add LTV materials.
prolongLtv() incrementally adds or refreshes the certificate chain and OCSP/CRL materials while preserving the signature field, appearance, and DocMDP reference.
CPDFPadesOptions options = new CPDFPadesOptions()
.setTrustedCertPath(trustedCertPath);
CPDFPadesResult result = CPDFPadesSigner.prolongLtv(
signedPath, ltvPath, null, options);
if (result != null && result.isSuccess()) {
String finalPath = result.getFinalPath();
// Open the final file and validate its signatures again.
}To append a document timestamp, set setAppendDocumentTimestamp(true) and setLtaTsaUrl(tsaUrl), and supply a separate ltaPath. This flow reads trust, revocation, and document timestamp options; it ignores profile, the signing certificate, field, and appearance options.
Android supplies no default OpenSSL trust store for this interface. Configure trusted root certificates explicitly. Inspect errors and warnings for network, chain, or material collection failures; an intermediate file's existence does not prove the entire operation succeeded.