PDFiumVCL Docs

FlattenAllPages method

Bu API girdisi tanımlayıcıları, imzaları, kod bloklarını ve PDF terimlerini özgün biçiminde korur.
Component: TPdf  ·  Unit: PDFium
Convenience wrapper that flattens every page in the document. Returns True when every page completes with FLATTEN_SUCCESS or FLATTEN_NOTHINGTODO. Recommended workflow: GenerateFormAppearances → FlattenAllPages → SaveAs.

Syntax

function FlattenAllPages(nFlag: Integer = FLAT_NORMALDISPLAY): Boolean;

nFlagInteger. Selects the flattening profile applied to every page. Pass FLAT_NORMALDISPLAY (0, default) to optimise for on-screen viewing, or FLAT_PRINT (1) to optimise for printed output.

Return Value

True if every page in the document returned either FLATTEN_SUCCESS (1) or FLATTEN_NOTHINGTODO (2); False if any page returned FLATTEN_FAIL (0).

Description

FlattenAllPages is a convenience wrapper that iterates over every page in the loaded document and calls the equivalent of FlattenPage on each one. Annotations and AcroForm widgets across all pages are merged into permanent, non-editable page content in a single call.

The method returns True only when all pages complete with FLATTEN_SUCCESS or FLATTEN_NOTHINGTODO. A single page returning FLATTEN_FAIL causes the method to return False, though flattening continues for the remaining pages.

When the document contains filled-in form fields, always call GenerateFormAppearances before FlattenAllPages. Without appearance streams the field values will not appear in the flattened output. The recommended full workflow is: assign FormField[] values → GenerateFormAppearancesFlattenAllPagesSaveAs.

To flatten a single page and inspect its individual result code use FlattenPage instead.

Example

begin
  // Fill fields, generate appearances, flatten entire document
  Pdf1.FormField[0] := 'Jane Doe';
  Pdf1.FormField[1] := '2026-05-20';
  Pdf1.GenerateFormAppearances;
  if Pdf1.FlattenAllPages(FLAT_NORMALDISPLAY) then
    Pdf1.SaveAs('output_flat_all.pdf')
  else
    ShowMessage('One or more pages could not be flattened');
end;

See Also

FlattenPage, GenerateFormAppearances, SaveAs