A very popular new feature of TX Text Control .NET for Windows Forms 15.0 is the Page Rendering Engine. It allows you to export metafiles or images from each separate page of TX Text Control. The content of the page is exactly the same content (rendering) like in an exported PDF or printed document.

Technically, the Page object of the PageCollection got a new method called GetImage with the following implementations:

public System.Drawing.Imaging.Metafile GetImage(PageContent contents)
public System.Drawing.Imaging.Bitmap GetImage(int zoomFactor, PageContent contents)
Text Control

The first implementation returns a Metafile that can be easily processed by using standard .NET classes. You could convert it to other image formats, print the metafile directly in a PrintDocument or scale it freely to your required size to display it in an image control. The right-hand diagram shows these possibilities.

The second implementation creates a Bitmap that can be saved as an image out-of-the-box without creating an image explicitely. You can specify the zoom factor in the GetImage method that should be used to create the high quality image of the specific page.

In both implementations, you need to specify the page content that should be exported. The following values are allowed:

  • All: The image contains all parts.
  • Background: The image contains the background of the page.
  • HeadersAndFooters: The image contains the header and the footer of the page.
  • MainText: The image contains the page's text contents.

The following code creates TIFF images from each page of the current document and stores them in an ArrayList.

ArrayList inputImages = new ArrayList();
foreach (Page page in textControl1.GetPages())
    MemoryStream image = new MemoryStream();
    Bitmap mf = page.GetImage(100, TXTextControl.Page.PageContent.All);
    mf.Save(image, ImageFormat.Tiff);

There are many different applications for this new feature and I am very interested in your solutions. Feel free to send me your ideas or questions you might have. What did you realize with the Page Rendering Engine?