PdfControl.Flatten Method

Flattens this control to its parent page. In effect, replaces the control with its appearance.

Namespace:  BitMiracle.Docotic.Pdf
Assembly:  BitMiracle.Docotic.Pdf (in BitMiracle.Docotic.Pdf.dll)

Syntax

C#
public void Flatten()
VB
Public Sub Flatten

Exceptions

ExceptionCondition
InvalidOperationException

Control does not have a parent page (Owner is null) or control is hidden (Hidden is true).

Remarks

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

This method flattens the control in 2 steps:

  1. Draws control on its parent page using text and vector graphics operators.
  2. Removes control from the document and from the Controls collection of its parent page.

NOTES:

  • Do not use this control after successful flattening. The flattened control is detached from its document.
  • This method modifies Controls collection so do not use Flatten() method within foreach (var control in page.Controls) loop.
  • 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