Teknik Makale

HotPDF Component: AcroForm fields and action logic 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ı developers replacing hand-edited PDF forms with deterministic Delphi form generation için hazırlanmıştır. AcroForm fields and action logic 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: field widgets can look correct while shared names, export values, JavaScript actions, tab order, or flattening rules break the receiving workflow. 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

Treat the field map as an application contract. field naming rules for repeated widgets and grouped business values / allowed trigger actions, submit targets, and viewer-side script policy

  • field naming rules for repeated widgets and grouped business values
  • allowed trigger actions, submit targets, and viewer-side script policy
  • required flags, default values, calculation order, and validation messages
  • whether the output remains interactive or is flattened for archive delivery

Uygulama akışı

Build the form layer before assigning values. Aşağıdaki sıra, iş akışını Delphi ve C++Builder ekipleri için incelenebilir tutar

  1. inventory the template fields and normalize names before binding application data
  2. apply values only after the allowed action profile has been selected
  3. refresh widget appearances with the same font and color policy used at design time
  4. validate exported values and tab order in the same viewer family used by customers
  5. flatten only after all required-field and calculation checks have passed

Doğrulama kanıtı

Evidence that proves the form is usable. Bu alanları çıktı veya destek kaydıyla birlikte saklayın

  • field name, widget bounds, page number, required state, and exported value
  • action type, trigger event, destination, and whether the profile allowed it
  • appearance stream status, font fallback decision, and calculated-field result
  • remaining interactive fields after flattening and warnings for unsupported actions

Appearance streams, actions, and flattening order

A production form workflow separates field creation, value assignment, appearance refresh, action binding, and final flattening. Keeping those phases visible makes it possible to explain why a required field failed or why a submit action was suppressed

Decision table for AcroForm fields and action logic

A decision table keeps product ownership visible when the same workflow is reused by a desktop tool, service job, and support utility

DecisionEngineering reasonEvidence
field naming rules for repeated widgets and grouped business valuesinventory the template fields and normalize names before binding application datafield name, widget bounds, page number, required state, and exported value
allowed trigger actions, submit targets, and viewer-side script policyapply values only after the allowed action profile has been selectedaction type, trigger event, destination, and whether the profile allowed it
required flags, default values, calculation order, and validation messagesrefresh widget appearances with the same font and color policy used at design timeappearance stream status, font fallback decision, and calculated-field result

Mühendislik inceleme notları: AcroForm fields and action logic

Ö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: field naming rules for repeated widgets and grouped business values. Uygulama baskı noktası: apply values only after the allowed action profile has been selected. Kabul kanıtı: appearance stream status, font fallback decision, and calculated-field result. Regresyon tetikleyicisi: flattening before validation can permanently hide incomplete or inconsistent data
  • Karar: allowed trigger actions, submit targets, and viewer-side script policy. Uygulama baskı noktası: refresh widget appearances with the same font and color policy used at design time. Kabul kanıtı: remaining interactive fields after flattening and warnings for unsupported actions. Regresyon tetikleyicisi: checkbox captions do not always match the export values consumed by external systems

Sınır durumları

  • checkbox captions do not always match the export values consumed by external systems
  • identically named fields may intentionally share one value across several pages
  • viewer security settings can block actions that worked during development
  • flattening before validation can permanently hide incomplete or inconsistent data

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 AcroForm, widget, field action, appearance stream, submit action, flattening

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 BuildAcroFormPackage(const OutputFile: string; const Profile: TFormProfile);
var
  Pdf: THotPDF;
begin
  Pdf := THotPDF.Create(nil);
  try
    Pdf.FileName := OutputFile;
    Pdf.BeginDoc;
    AddCustomerFields(Pdf, Profile);
    WireSubmitActions(Pdf, Profile.ActionMap);
    ValidateRequiredFields(Profile.RequiredFields);
    Pdf.EndDoc;
  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

// Open a help page in the system browser
Pdf.CurrentPage.AddPushButtonWithAction('btnHelp', 'Help',
  'https://www.example.com/claims-help', Rect(320, 700, 420, 730), baURI);

// Run viewer-side JavaScript
Pdf.CurrentPage.AddPushButtonWithAction('btnRecalc', 'Recalculate',
  'app.alert("Totals updated.");', Rect(320, 660, 420, 690), baJavaScript);

// Submit as XFDF and keep empty fields in the payload
Pdf.CurrentPage.AddPushButtonWithSubmitAction('btnSubmit', 'Submit claim',
  'https://api.example.com/claims', Rect(320, 620, 420, 650),
  [sffXFDF, sffIncludeNoValueFields]);
// Reject committed values that are not plausible email addresses
Pdf.AttachFieldKeyStrokeAction('applicant.email',
  'if (event.willCommit && !/^[\w.-]+@[\w.-]+\.\w+$/.test(event.value)) event.rc = false;');

// Display US phone numbers as (NNN) NNN-NNNN
Pdf.AttachFieldFormatAction('applicant.phone',
  'event.value = event.value.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3");');

// Refuse applicants under 18 at commit time
Pdf.AttachFieldValidateAction('applicant.age',
  'if (parseInt(event.value) < 18) event.rc = false;');