New to Telerik Document ProcessingStart a free 30-day trial

FormSource

Updated on Jun 3, 2026

With FormSource you can add content to a Form object and insert it in the PDF document. The following sections are covered:

The FormSource content can also be an SVG image or a Barcode.

Creating a FormSource

The FormSource class exposes a default constructor that you can use to create an empty instance.

Example 1: Create FormSource

C#
FormSource formSource = new FormSource();

The snippet from Example 1 creates an empty FormSource object. To fill this object with content, use FixedContentEditor as described later in this article.

The FormSource class exposes the following properties:

PropertyDescription
SizeGets or sets the size of the form.
ContentGets the contents of the form.

Adding Content to a FormSource Object

The FormSource class inherits from the IContentRootElement interface. This inheritance allows you to use the FixedContentEditor class to fill the content of the form.

Example 2 shows how to insert content into a FormSource object by using FixedContentEditor.

There is no nesting limit for Form XObjects, but PDF viewers may restrict depth to avoid memory or performance issues and improve responsiveness. This restriction can affect rendering depending on the viewer.

Example 2: Add content to a FormSource

C#
FormSource simpleForm = new FormSource();
simpleForm.Size = new Size(310, 250);

FixedContentEditor formEditor = new FixedContentEditor(simpleForm);
formEditor.Position.Translate(50, 60);

using (formEditor.SaveProperties())
{
    formEditor.GraphicProperties.IsFilled = true;
    formEditor.GraphicProperties.IsStroked = true;
    formEditor.GraphicProperties.StrokeThickness = 2;
    formEditor.GraphicProperties.StrokeColor = new RgbColor(92, 229, 0);
    formEditor.GraphicProperties.FillColor = new RgbColor(213, 222, 226);
    formEditor.GraphicProperties.StrokeDashArray = new double[] { 17, 4 };
    formEditor.DrawRectangle(new Rect(0, 0, 250, 150));
}

formEditor.Position.Translate(100, 120);
formEditor.DrawText("Sample rectangle in a form");

Inserting a FormSource into a Document

After you generate the FormSource object and fill it with content, insert it in the document. The API provides you with several approaches to insert the form in different scenarios.

You can reuse a single FormSource object across the document by setting it to different Form instances.

  • The FixedContentEditor allows you to add a form to a container.

    Example 3: Add a FormSource to a document using FixedContentEditor

    C#
    FixedContentEditor documentPageEditor = new FixedContentEditor(document.Pages.AddPage());
    
    FormSource simpleForm = new FormSource();
    // Fill the FormSource instance with content (you can use the code from Example 2)
    
    documentPageEditor.DrawForm(simpleForm);

    There are several overloads of the DrawForm() method that let you specify the size of the form.

  • You can insert a FormSource object by using the methods of RadFixedDocumentEditor. The InsertFormInline() method is described in the RadFixedDocumentEditor article.

  • When editing a Block, you can insert a FormSource object directly into it. For more information, see the Block article.

See Also