[C#] Example 1: Create RadFixedDocumentEditor

RadFixedDocumentEditor inherits from IDisposable so it should be properly disposed when the document is created. Otherwise, some of the content may not be finished, i.e. it might not appear on the PDF document.

The first section of a document starts as soon as a content is inserted to the editor. You can change the Section properties before inserting any content and they will be applied to the section that is automatically created.

Adding an additional section is achieved with the InsertSectionBreak() method as demonstrated in Example 2.

[C#] Example 2: Start a section

editor.InsertSectionBreak();

If you want to change the properties of the next section, make sure to do it before you insert the section break. New properties are only used for newly created sections.

The first paragraph is created as soon as content is inserted in the editor. You can change paragraph properties before inserting content and when the first paragraph is created automatically, it will use the desired properties.

In order to start a new paragraph, use the code in Example 4.

[C#] Example 4: Start a paragraph

editor.InsertParagraph();

The result of this method is that a new paragraph is started and it uses the current paragraph properties. Until a new paragraph is started, changes in the paragraph properties are not applied.

There are a number of overloads that insert a run. The code snippet in Example 5 inserts new runs with specific font family, style and weight.

[C#] Example 5: Insert run

editor.InsertRun("text");
editor.InsertRun(fontFamily, "text");

There are a number of overloads that insert a run. The code snippet in Example 5 inserts a couple of new runs, one of which with a specific font family.

The '\r' and '\n' characters don't have the usual meaning of "go to next line" when they are inserted into a PDF document and you cannot simply insert text containing these characters to produce multiline text. Instead, you should split the text and insert a line break.

[C#] Example 7: Insert image

The Table class implements the IBlockElement interface and an instance of this class can be easily inserted as a new block in the document. You could insert the table using the InsertTable() method like illustrated in Example 8. RadFixedDocumentEditor takes care for positioning, measuring and splitting the table onto pages.

[C#] Example 8: Insert table

editor.InsertTable(table);

For more detailed information on tables, check the Table documentation article.

The IBlockElement interface allows you to easily draw and split some block content onto pages. The interface is implemented by Block and Table classes. You can easily add some block element instance with RadFixedDocumentEditor using the InsertBlock() method like illustrated in Example 9.

[C#] Example 9: Insert Block element

You can easily insert list items with RadFixedDocumentEditor. The first thing you have to do is add a List in editor’s ListCollection by using the Lists property. Then, each time you want to add list item you have to set the appropriate ListId and ListLevel property values through RadFixedDocumentEditor’s ParagraphProperties. Inserting a new paragraph will result in adding a new list item.

The following code snippet shows how to add a new list to RadFixedDocumentEditor’s ListCollection and after that insert a paragraph with the corresponding list properties: