Flattens this widget to its parent page. In effect, replaces the control with its appearance.
public void Flatten()
Flattening locks widget from editing. Flattening can significantly reduce file
size if RemoveUnusedObjects property is set to
This method flattens the widget in 2 steps:
- Draws the widget on its parent page using text and vector graphics operators.
- Removes the widget from the document and from the Widgets collection of its parent page. Controls are also removed from the Controls collection.
The method won't draw anything for invisible widgets or widgets without a parent page. The widget visibility is controlled by the Hidden and NoView properties. Also, controls and some other widget types might be invisible if they do not provide an appearance stream.
- Do not use this widget after successful flattening. The flattened control is detached from its document.
This method modifies Widgets and Controls collections
so do not use the Flatten() method within
foreach (var control in page.Controls)or
foreach (var widget in page.Widgets)loops.
- This method can change graphics state of the page. To avoid possible side effects, call the method right before saving of the document.
- See Also