Teknik makale

HotPDF: object streams and incremental updates in Delphi

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ı engineers maintaining PDFs that may already contain signatures, revisions, compressed objects, or repair history için hazırlanmıştır. object streams and incremental updates 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: rewriting a file as if it were newly generated can discard revision history, break signatures, or hide damaged cross-reference data. 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

Understand the existing revision chain. whether existing signatures or audit trails must remain valid / policy for object stream preservation, decompression, or recompression

  • whether existing signatures or audit trails must remain valid
  • policy for object stream preservation, decompression, or recompression
  • repair handling when cross-reference data is inconsistent
  • metadata and catalog updates that should be appended instead of rewritten

Uygulama akışı

Choose full rewrite or incremental save deliberately. Aşağıdaki sıra, iş akışını Delphi ve C++Builder ekipleri için incelenebilir tutar.

  1. inspect the source for signatures, xref streams, object streams, and prior revisions
  2. select incremental update only when the business goal requires preservation
  3. write changed objects to a new revision and leave untouched objects stable
  4. verify signatures, object counts, and cross-reference consistency after saving
  5. record the reason if a full rewrite was required for repair or normalization

Doğrulama kanıtı

Revision evidence to capture. Bu alanları çıktı veya destek kaydıyla birlikte saklayın.

  • source revision count, signature presence, xref style, and object stream count
  • save mode, changed object identifiers, and whether object streams were preserved
  • validator output before and after the update
  • signature status for every signed revision after the final file is written

Compressed objects change support diagnostics

Object streams, hybrid cross-reference tables, and incremental saves are normal in modern PDFs. The workflow should know whether it is preserving a revision, appending a new revision, or creating a clean output file.

Review questions before release

Before this reaches production, the team should be able to answer these questions without reading source code.

  • Who owns whether existing signatures or audit trails must remain valid?
  • What evidence proves source revision count, signature presence, xref style, and object stream count?
  • What happens when a full rewrite can invalidate signatures even when visible content is unchanged?
  • Which regression file covers record the reason if a full rewrite was required for repair or normalization?

Mühendislik inceleme notları: object streams and incremental updates

Ö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: whether existing signatures or audit trails must remain valid. Uygulama baskı noktası: select incremental update only when the business goal requires preservation. Kabul kanıtı: validator output before and after the update. Regresyon tetikleyicisi: object-stream compression can make diff-based support investigations misleading
  • Karar: policy for object stream preservation, decompression, or recompression. Uygulama baskı noktası: write changed objects to a new revision and leave untouched objects stable. Kabul kanıtı: signature status for every signed revision after the final file is written. Regresyon tetikleyicisi: a full rewrite can invalidate signatures even when visible content is unchanged
  • Karar: repair handling when cross-reference data is inconsistent. Uygulama baskı noktası: verify signatures, object counts, and cross-reference consistency after saving. Kabul kanıtı: source revision count, signature presence, xref style, and object stream count. Regresyon tetikleyicisi: repairing a damaged file may require a support note explaining lost revisions
  • Karar: metadata and catalog updates that should be appended instead of rewritten. Uygulama baskı noktası: record the reason if a full rewrite was required for repair or normalization. Kabul kanıtı: save mode, changed object identifiers, and whether object streams were preserved. Regresyon tetikleyicisi: linearization can be lost after incremental updates unless the workflow rebuilds it
  • Karar: whether existing signatures or audit trails must remain valid. Uygulama baskı noktası: inspect the source for signatures, xref streams, object streams, and prior revisions. Kabul kanıtı: validator output before and after the update. Regresyon tetikleyicisi: object-stream compression can make diff-based support investigations misleading
  • Karar: policy for object stream preservation, decompression, or recompression. Uygulama baskı noktası: select incremental update only when the business goal requires preservation. Kabul kanıtı: signature status for every signed revision after the final file is written. Regresyon tetikleyicisi: a full rewrite can invalidate signatures even when visible content is unchanged
  • Karar: repair handling when cross-reference data is inconsistent. Uygulama baskı noktası: write changed objects to a new revision and leave untouched objects stable. Kabul kanıtı: source revision count, signature presence, xref style, and object stream count. Regresyon tetikleyicisi: repairing a damaged file may require a support note explaining lost revisions

Sınır durumları

  • a full rewrite can invalidate signatures even when visible content is unchanged
  • repairing a damaged file may require a support note explaining lost revisions
  • linearization can be lost after incremental updates unless the workflow rebuilds it
  • object-stream compression can make diff-based support investigations misleading

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 object stream, incremental update, xref stream, revision, signature preservation, repair.

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 SaveCompactIncrementalPdf(const OutputFile: string);
var
  Pdf: THotPDF;
begin
  Pdf := THotPDF.Create(nil);
  try
    Pdf.FileName := OutputFile;
    Pdf.UseXRefStream := True;
    Pdf.UseObjectStreams := True;
    Pdf.BeginDoc;
    AddRevisionContent(Pdf);
    Pdf.EndDoc;
    CompareObjectStreamProfile(OutputFile);
  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

HotPDF Component

Ek kod örnekleri

Pdf.BeginIncrementalUpdate('contract-signed.pdf');
Pdf.AddPage;
Pdf.CurrentPage.SetFont('Arial', [], 10);
Pdf.CurrentPage.TextOut(50, 760, 0, 'Addendum recorded 2026-06-11');
Pdf.SaveIncrementalUpdate('contract-updated.pdf');  // appends the delta only
PageCount := Pdf.LoadFromFile('base.pdf');
Pdf.InsertPagesFromDocument(OtherDoc, '1-3', 5);  // pages 1-3 after page 5
Pdf.MovePage(2, 5);
Pdf.SaveLoadedDocument('modified.pdf');
Pdf.LoadFromFile('stamped.pdf');
Pdf.SaveLoadedDocument('compacted.pdf');