Nevron Open Vision Documentation
Rich Text Editor / Document Model / Inlines / Image Inlines
In This Topic
    Image Inlines
    In This Topic

    Image inlines allow you to insert raster and vector images inside paragraph contents.

     Creating Image Inlines

    Image inline elements are represented by instances of the NImageInline class. The following code shows how to create a paragraph that contains a bitmap image:

    Creating Raster Image Inlines
    Copy Code
    NSection section = new NSection();
    
    NParagraph paragraph = new NParagraph();
    paragraph.Inlines.Add(new NTextInline("Tablet image: "));
    
    NImageInline imageInline = new NImageInline();
    imageInline.Image = NImage.FromFile("C:\\tablet.jpg"));
    paragraph.Inlines.Add(imageInline);
    
    section.Blocks.Add(paragraph);
    
    m_RichText.Content.Sections.Clear();
    m_RichText.Content.Sections.Add(section);
    

    This code will result in the following text output:

    By default, the image inline will have a size that is equal to the image width and height. If you want to stretch the image so that it looks smaller or bigger you can modify its PreferredWidth and PreferredHeight properties. For example:

    Setting PreferredWidth and PreferredHeight
    Copy Code
    rasterImage.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 100);
    rasterImage.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 100);
    

    Tells the control to scale the image so that its width and height become 100 dips.

     Vector Images

    Image inlines can also display WMF and EMF vector images (metafiles), which are commonly used in Microsoft Word like applications to embed vector images. Metafiles are scalable images, which allows them to print or export to PDF without loss of quality. You can embed vector images in the same way you embed raster images - simply load the vector image as an NImage instance and place it in an image inline. The following code snippet shows how to embed a metafile image inside a paragraph:

    Creating Metafile Image Inlines
    Copy Code
    NImageInline imageInline = new NImageInline();
    imageInline.Image = NImage.FromFile("C:\\MyMetafileImage.emf");
    paragraph.Inlines.Add(imageInline);
    

    Similarly to image inlines containing raster images you can use the PreferredWidth and PreferredHeight properties of the image inline to set the width and height of the image inline explicitely.

     

    See Also