Table of Contents

Method FlattenWidgets



Flattens all widgets in the document. In effect, replaces widgets with their appearance. Putting it differently, merges widgets down on to their respective pages.

public void FlattenWidgets()


Flattening locks widgets from editing. Flattening can significantly reduce file size if RemoveUnusedObjects property is set to true.

This method enumerates all widgets in the document and flattens every widget in 2 steps:

  1. Draws the widget on its parent page using text and vector graphics operators.
  2. Removes the widget from the Widgets collection of its parent page. Controls are also removed from the Controls collection.

This method flattens both widgets (annotations) and controls. To flatten controls only, use the FlattenControls() method. To flatten only certain widgets or controls, process them individually using the Flatten() method.

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.

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