HotPDF, harici bir PDF runtime kurmadan doğrudan PDF oluşturma ve düzenleme, formlar, notlar, şifreleme, dijital imzalar, Unicode yazı tipleri, standart odaklı çıktı ve preflight raporları gereken Delphi ve C++Builder uygulamaları için yerel bir VCL PDF kütüphanesidir.
Bu yazı Delphi ekipler için certificate-based approval, invoice signing, or long-term validation evidence için hazırlanmıştır. digital signatures and PAdES-ready signing konusunu tek bir bileşen çağrısı olarak değil, üretim düzeyinde belge mühendisliği olarak ele alır.
Pratik risk şudur: a PDF may contain a visible signature box while the byte range, certificate chain, timestamp, revocation data, or later incremental update invalidates trust. Bu nedenle akışın yazılı sözleşmeye, gözlemlenebilir tanılara ve gerçekçi regresyon dosyalarına ihtiyacı vardır.
Mimari kararlar
Design signing as a revision-controlled workflow. certificate source, private-key boundary, and operator approval process / timestamp authority, revocation source, and long-term validation profile
- certificate source, private-key boundary, and operator approval process
- timestamp authority, revocation source, and long-term validation profile
- visible signature appearance, signer reason, contact, and location fields
- whether later annotations, forms, or metadata updates are allowed after signing
Uygulama akışı
Prepare evidence before reserving the signature field. Aşağıdaki sıra, iş akışını Delphi ve C++Builder ekipleri için incelenebilir tutar.
- freeze the document content and preflight it before signature reservation
- load certificate material from the approved key store or signing service
- reserve the signature field and byte range with enough space for the final value
- apply timestamp and revocation data according to the selected PAdES profile
- verify the final file in at least one independent validator before release
Doğrulama kanıtı
Signature evidence worth keeping. Bu alanları çıktı veya destek kaydıyla birlikte saklayın.
- signer certificate fingerprint, chain status, timestamp result, and revocation source
- signature byte range, digest algorithm, PAdES profile, and validation summary
- document hash before signing and final hash after the signed revision is saved
- policy decision for any warning that did not block the signature
PAdES is a lifecycle, not only a signature
PAdES-ready output needs deterministic document bytes, a verified certificate context, timestamp policy, revocation evidence, and a save strategy that does not alter signed byte ranges after the signature is applied.
Profile ownership and versioning
A named, versioned profile is easier to review than options scattered across forms, scripts, and batch parameters. It also makes support reports readable when customers use older templates or policies.
- certificate source, private-key boundary, and operator approval process
- timestamp authority, revocation source, and long-term validation profile
- visible signature appearance, signer reason, contact, and location fields
- whether later annotations, forms, or metadata updates are allowed after signing
- signer certificate fingerprint, chain status, timestamp result, and revocation source
- signature byte range, digest algorithm, PAdES profile, and validation summary
Mühendislik inceleme notları: digital signatures and PAdES-ready signing
Özelliğin bir demoyu aşıp sürüm, destek ve müşteri eskalasyonu sırasında savunulabilir olduğunu doğrulamak için bu inceleme notlarını kullanın.
- Karar: certificate source, private-key boundary, and operator approval process. Uygulama baskı noktası: load certificate material from the approved key store or signing service. Kabul kanıtı: document hash before signing and final hash after the signed revision is saved. Regresyon tetikleyicisi: timestamp and revocation services need timeout and retry policies
- Karar: timestamp authority, revocation source, and long-term validation profile. Uygulama baskı noktası: reserve the signature field and byte range with enough space for the final value. Kabul kanıtı: policy decision for any warning that did not block the signature. Regresyon tetikleyicisi: editing metadata or form values after signing can invalidate the signed revision
- Karar: visible signature appearance, signer reason, contact, and location fields. Uygulama baskı noktası: apply timestamp and revocation data according to the selected PAdES profile. Kabul kanıtı: signer certificate fingerprint, chain status, timestamp result, and revocation source. Regresyon tetikleyicisi: certificate chain checks can pass on a developer machine but fail offline
- Karar: whether later annotations, forms, or metadata updates are allowed after signing. Uygulama baskı noktası: verify the final file in at least one independent validator before release. Kabul kanıtı: signature byte range, digest algorithm, PAdES profile, and validation summary. Regresyon tetikleyicisi: visible appearance text should not be treated as cryptographic evidence
- Karar: certificate source, private-key boundary, and operator approval process. Uygulama baskı noktası: freeze the document content and preflight it before signature reservation. Kabul kanıtı: document hash before signing and final hash after the signed revision is saved. Regresyon tetikleyicisi: timestamp and revocation services need timeout and retry policies
Sınır durumları
- editing metadata or form values after signing can invalidate the signed revision
- certificate chain checks can pass on a developer machine but fail offline
- visible appearance text should not be treated as cryptographic evidence
- timestamp and revocation services need timeout and retry policies
Delphi / C++Builder notes
HotPDF Component should sit behind a small service boundary that receives files, streams, profiles, and credentials, then returns output paths, warnings, metrics, and validation status. Important terms include PAdES, digital signature, byte range, timestamp, DSS, revocation.
Delphi kod örneği
Aşağıdaki Delphi taslağı bu konu için pratik bir servis sınırını gösterir. Politika kontrollerini, günlüklemeyi ve doğrulamayı dar ürün çağrısı bölümünün dışında tutarak akışı test edilebilir bırakın.
procedure SignApprovedPdf(const InputFile, OutputFile: string; const Policy: TSignaturePolicy);
var
Pdf: THotPDF;
begin
Pdf := THotPDF.Create(nil);
try
LoadUnsignedPackage(Pdf, InputFile);
CheckSigningPolicy(Policy);
AttachPadesEvidence(Pdf, Policy.Certificate, Policy.TimestampServer);
SaveSignedPackage(Pdf, OutputFile);
ValidateSignatureChain(OutputFile, Policy.TrustAnchors);
finally
Pdf.Free;
end;
end;
Üretim kontrol listesi
- İş akışını boş bir dosyada, normal bir müşteri dosyasında ve en kötü durum dosyasında çalıştırın
- Oluşturulan PDF'yi hedef görüntüleyici, doğrulayıcı, yazıcı veya aşağı akış uygulamasıyla açın
- Ürün sürümünü, profil sürümünü, giriş karmasını, çıktı yolunu, geçen süreyi ve uyarı sayısını kaydedin
- Parolaları, sertifikaları, geçici dosyaları ve müşteri verilerini açık saklama kuralları altında tutun
- Bir müşteri dosyası yeni bir uç durum ortaya çıkardığında regresyon belgeleri ekleyin
Ürün belgeleri
Ek kod örnekleri
var
Doc: THotPDF;
Fs: TFileStream;
PdfBytes, HashInput, SigHex: AnsiString;
R1Start, R1Len, R2Start, R2Len, CStart, CLen: Integer;
begin
// 1. Write the document with a reserved /Contents hole
Doc := THotPDF.Create(nil);
try
Doc.FileName := 'placeholder.pdf';
Doc.BeginDoc;
Doc.CurrentPage.AddSignedSignatureField('Sig1',
Rect(50, 100, 350, 150), 8192, 'adbe.pkcs7.detached',
'Contract approval', 'Boston, MA', 'legal@example.com');
Doc.EndDoc;
finally
Doc.Free;
end;
// 2. Load the saved bytes; the returned offsets are 0-based
Fs := TFileStream.Create('placeholder.pdf', fmOpenRead);
try
SetLength(PdfBytes, Fs.Size);
Fs.ReadBuffer(PdfBytes[1], Fs.Size);
finally
Fs.Free;
end;
THotPDF.PreparePDFForSigning(PdfBytes, R1Start, R1Len, R2Start, R2Len,
CStart, CLen);
// 3. Hash both spans and sign externally (HSM, token, service)
HashInput := Copy(PdfBytes, R1Start + 1, R1Len) +
Copy(PdfBytes, R2Start + 1, R2Len);
SigHex := SignWithHsm(HashInput); // your integration: returns CMS as hex
// 4. Splice the signature into the reserved hole
THotPDF.InsertSignatureHex(PdfBytes, SigHex);
Fs := TFileStream.Create('signed.pdf', fmCreate);
try
Fs.WriteBuffer(PdfBytes[1], Length(PdfBytes));
finally
Fs.Free;
end;
end;// PAdES baseline signature field (ETSI EN 319 142-1)
Pdf.CurrentPage.AddPAdESSignatureField(
'ApprovalSig', Rect(50, 100, 350, 150), 'B-B',
'Contract approval', 'Boston, MA', 'legal@example.com');
// Document timestamp: larger reservation for the TSA token and chain
Pdf.CurrentPage.AddDocumentTimestampSignature('ArchiveTS', 16384);