THotPDF 已載入表單欄位編輯方法
本參考主題說明 HotPDF 函式庫中公開 API 的行為、參數與使用方式
欄位層級方法
procedure SetLoadedFormFieldFlags(FieldIndex, AFlags: Integer);
procedure SetLoadedFormFieldMaxLength(FieldIndex, AMaxLength: Integer);
procedure SetLoadedFormFieldJustification(FieldIndex: Integer;
AJustification: THPDFFormFieldJustification);
procedure SetLoadedFormFieldTooltip(FieldIndex: Integer; const ATooltip: AnsiString);
SetLoadedFormFieldFlags會取代完整的 PDF/Ff位元遮罩SetLoadedFormFieldMaxLength寫入/MaxLen;零或負值會移除長度限制THPDFFormFieldJustification包含ffjLeft、ffjCenter、ffjRight,對應 PDF/Q值 0 到 2
Widget 幾何
function GetLoadedFormFieldWidgetCount(FieldIndex: Integer): Integer;
function GetLoadedFormFieldWidgetRect(FieldIndex, WidgetIndex: Integer;
out ARect: THPDFRect): boolean;
procedure SetLoadedFormFieldWidgetRect(FieldIndex, WidgetIndex: Integer;
X1, Y1, X2, Y2: Single);
- 欄位與 widget 索引皆為零基
- Widget 列舉會公開 radio group 與其他多 widget 欄位的每一個
/Kids項目 - 矩形端點使用原始 PDF user-space 點,寫入前會先正規化
Widget 外觀與可見性
procedure SetLoadedFormFieldRotation(FieldIndex, ADegrees: Integer);
procedure SetLoadedFormFieldBorderColor(FieldIndex: Integer;
ARed, AGreen, ABlue: Single);
procedure SetLoadedFormFieldVisibility(FieldIndex: Integer;
AVisible, APrintable: boolean);
procedure SetLoadedFormFieldBorderWidth(FieldIndex: Integer; AWidth: Single);
procedure SetLoadedFormFieldBackgroundColor(FieldIndex: Integer;
ARed, AGreen, ABlue: Single);
- 旋轉接受正負 90 度的倍數,並儲存正規化後的
/MK /R值 - 邊框與背景的 RGB 分量會限制在 PDF DeviceRGB 的 0 到 1 範圍
- 外觀與可見性 setter 會更新所選欄位的每一個 widget
- 可見性控制在 Hidden、NoView 與 Print 的同時,保留不相關的註解旗標
增量更新行為
- 欄位、widget、
/MK與/BS字典都在各自數值所在的層級標記為 dirty - 視覺變更只會使受影響頁面的快取 DPI 變體失效
- 欄位或 widget 索引無效時,文件保持不變
範例
PDF.BeginIncrementalUpdate('input.pdf');
PDF.SetLoadedFormFieldMaxLength(0, 40);
PDF.SetLoadedFormFieldJustification(0, ffjCenter);
PDF.SetLoadedFormFieldRotation(0, 90);
PDF.SetLoadedFormFieldBorderColor(0, 0.1, 0.4, 0.8);
PDF.SetLoadedFormFieldWidgetRect(1, 1, 80, 150, 100, 170);
PDF.SaveIncrementalUpdate('updated.pdf');