Nevron Open Vision Documentation
Image Inlines

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


This topic contains these sections:
Creating Raster Image Inlines

Raster image inlines elements are represented by instances of the NRasterImageInline 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: "));

NRasterImageInline rasterImage = new NRasterImageInline();
rasterImage.Image = NImage.FromFile("C:\\tablet.jpg"));
paragraph.Inlines.Add(rasterImage);

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 which 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.

Metafile Image Inlines

Nevron Text supports WMF and EMF vector image formats (metafile), which are commonly used in MS Word like applications to embed vector images. Metafiles are scalable images, which allows them to print or export to PDF without loss of quality. The following code snippet shows how to embed a metafile image inside a paragraph:

Creating Metafile Image Inlines
Copy Code
NMetafileImageInline metaImageInline = new NMetafileImageInline();
metaImageInline.MetaImage = NMetaImage.FromFile("C:\\MyMetafileImage.emf");
paragraph.Inlines.Add(metaImageInline);

Similarly to raster image inlines you can control the PreferredWidth and PreferredHeight of the image.

 

See Also
Send Feedback