In order to insert an image into a document, an Image TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
Image Class
Image Constructor
Initializes a new instance of the Image class.
object must be created. In the first example, an image is created from a physical file:

Loading...

According to the documentation, it is required to provide the import filter index in the constructor of the Image class. The index can be retrieved using the ImportFilters TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
ImageCollection Class
ImportFilters Property
Gets all available filters for importing images.
property. But technically, you can provide any index and TX Text Control is recognizing the image format automatically (but it might take a little longer).

Another way to create an Image object is to provide a System.Drawing.Image in the constructor. In this case, you can create any bitmap image and load it into the Text Control:

Loading...

Images from a Stream

In a third implementation, an image can be created from a stream. The MemoryStream must be publicly visible as Text Control is accessing the stream when the image is actually added to the document:

Loading...

All of the above samples insert the image at a text position and the image is handled inline like a character. The following insertion modes are available:

  • Inline with text
  • Anchored to a paragraph
  • Fixed on a page

Combine Insertion Modes

The following InsertionModes TX Text Control .NET for Windows Forms
TXTextControl Namespace
TXTextControl Enumerations Enumerations
ImageInsertionMode Enumeration Enumeration
Determines how an Image can be inserted in the text.
are supported:

Member Description
AsCharacter The image is inserted in the text as a single character.
DisplaceCompleteLines The image is inserted at a certain geometrical location. The text stops at the top and continues at the bottom of the image.
DisplaceText The image is inserted at a certain geometrical location. The text flows around the image and empty areas at the left and right side are filled.
AboveTheText The image is inserted at a certain geometrical location above the text. This means that the image overwrites the text.
BelowTheText The image is inserted at a certain geometrical location below the text. This means that the text overwrites the image.
MoveWithText The image is connected with a paragraph and moved with the text.
FixedOnPage The image is fixed positioned on a page.

The values of the ImageInsertionMode enumeration can be combined. The following combinations are possible:

  • DisplaceCompleteLines | MoveWithText
  • DisplaceCompleteLines | FixedOnPage
  • DisplaceText | MoveWithText
  • DisplaceText | FixedOnPage
  • AboveTheText | MoveWithText
  • AboveTheText | FixedOnPage
  • BelowTheText | MoveWithText
  • BelowTheText | FixedOnPage
  • AsCharacter

Anchored to Paragraphs

For example, the following code inserts an image that is anchored to the paragraph at the current input position with a location offset of 500 twips in both directions:

Loading...

The location is given in twips at which the image is to be inserted. This is a location relative to the top left corner either of a page or a paragraph.

Image location