FlattenFormFieldsOnPageRange
Form fields
Description
Merges the appearance of every form field on the listed pages into the page content and removes the interactive fields. It returns the number of fields flattened, or 0 when the document carries no form data or the range selects no page; an empty range means all pages.
Syntax
Delphi
Function TPDFlib.FlattenFormFieldsOnPageRange(Const PageRange: WideString): Integer;
Parameters
PageRange lists the pages to flatten in the library's usual range syntax, such as 1,3,5-9; an empty string selects every page. Only widgets whose page falls inside the range are flattened, so a field also shown on other pages stays interactive there.
Return values
The number of fields flattened, counting only fields whose widgets on the selected pages were all merged into the page content and removed. The value is 0 when no document is open, the document has no form data, the range names no page, or no field on those pages has a usable appearance.
Remarks
Existing appearance streams are baked in as they are; appearances are not regenerated, so a widget without a usable normal appearance stays interactive and is not counted, and fields whose values changed since the last appearance build should be regenerated first with UpdateAndFlattenFormField. A field whose widgets are spread over several pages loses only those inside the range, is removed once none remains, and any ancestors it empties are pruned. The field list is walked over a snapshot of object numbers because flattening mutates it, and the previously selected page is restored before returning. Use FlattenFormFieldsTaggedOnPageRange when the field's marked-content tag must be preserved for a tagged document.