# Form

`Form` is a content element that contains a form source and represents a Form XObject. Form XObjects allow you to describe objects (text, images, vector elements, and so on) within a PDF file and reuse this content throughout the document.

* [Creating and Inserting a Form](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/form#creating-and-inserting-a-form)
* [Form Properties](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/form#form-properties)

## Public API

| **Property**          | **Description**                                                                                                                                                                                              |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `FormSource`          | Specifies the content that the Form object visualizes. It is of type [FormSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/overview). |
| `Clipping`            | Gets or sets the clipping of the form object.                                                                                                                                                                |
| `Width`               | The width of the form.                                                                                                                                                                                       |
| `Height`              | The height of the form.                                                                                                                                                                                      |
| `AlphaConstant`       | Specifies the constant shape or constant opacity value for nonstroking operations.                                                                                                                           |
| `StrokeAlphaConstant` | Specifies the constant shape or constant opacity value for stroking operations.                                                                                                                              |
| `Position`            | The [Position](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/position) of the form inside the `IContainerElement`.                                 |
| `Parent`              | Gets the parent page of the form.                                                                                                                                                                            |

| **Method**                      | **Description**                               |
| ------------------------------- | --------------------------------------------- |
| `Clone` (starting with Q2 2025) | Creates a deep copy of this document element. |

### Creating and Inserting a Form

The `Form` class exposes a default public constructor that allows you to create instances of it. `Form` is a content element and you can add such an object to the `Content` collection of an `IContainerElement` such as [RadFixedPage](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/radfixedpage).

**Example 1** shows how to initialize a `Form` object and add it to a previously defined container.

**Example 1: Create a form and add it to an IContainerElement**

```C#
Form emptyForm = new Form();
container.Content.Add(emptyForm);
```

**Example 2** demonstrates how to use one of the factory methods of the `ContentElementCollection` to create a new form and insert it into the respective container.

**Example 2: Add a form to a container**

```C#
Form form = container.Content.AddForm();
Form formWithSource = container.Content.AddForm(sampleFormSource);
```

> tip There are other methods that allow adding a form to a document by passing its size and source. You can use them through the [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor) class.

> You can add content to the form by setting its `FormSource` property. The API also allows you to directly pass the `FormSource` to a method that automatically generates a form in the document content. For more information, see the [FormSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/overview) article.

> There is no nesting limit for [Form XObjects](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/form), but PDF viewers may restrict depth to avoid memory or performance issues and improve responsiveness. This can affect rendering depending on the viewer.

### Modifying Form Properties

You can modify a `Form` element using the properties the class exposes. The properties are listed in the [Public API](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/form#public-api) section.

**Modify Form properties**

```C#
RadFixedDocument document = new RadFixedDocument();

RadFixedPage page = document.Pages.AddPage();
FormSource formSource = new FormSource();
formSource.Size = new Size(200, 200);
Form newForm = page.Content.AddForm(formSource);

SimplePosition simplePosition = new SimplePosition();
simplePosition.Translate(20, 20);

newForm.Width = 200;
newForm.Height = 300;
newForm.Position = simplePosition;
newForm.AlphaConstant = 0.5;
newForm.StrokeAlphaConstant = 0.1;

PathGeometry pathGeometry = new PathGeometry();
PathFigure pathFigure = pathGeometry.Figures.AddPathFigure();
pathFigure.StartPoint = new Point(5, 5);
LineSegment lineSegment = pathFigure.Segments.AddLineSegment();
lineSegment.Point = new Point(205, 5);
BezierSegment bezierSegment = pathFigure.Segments.AddBezierSegment();
bezierSegment.Point1 = new Point(105, 50);
bezierSegment.Point2 = new Point(130, 105);
bezierSegment.Point3 = new Point(100, 200);
pathFigure.IsClosed = true;

FixedContentEditor editor = new FixedContentEditor(formSource);
editor.DrawPath(pathGeometry);
```

![PdfProcessing Modify Form Properties](https://www.telerik.com/document-processing-libraries/documentation/assets/21b586f017a7dd7a285d475d02870e2a/pdf-processing-modify-form-properties.png)

## See Also

* [FormSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/overview)
* [RadFixedPage](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/radfixedpage)
* [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor)
* [Position](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/position)
