VegaRise.NET

Images

Add images with doc.AddImage(...) or paragraph.AddImage(...). Images share the same positioning API as shapes (SetPosition,SetDimensions, SetRotation, wrapping, margins).

Load and Position an Image

Use case: Place a logo at a fixed page position with an explicit size.

C#
1using Vega;
2using Vega.DOM;
3using DOM.Enums;
4
5var doc = new VDocs();
6
7var image = doc.AddImage("logo.png");
8image.SetPosition(100, 200, Units.pt);
9image.SetDimensions(300, 200, Units.pt);
10image.SetRotation(15);
11
12doc.SaveAsWord("with-image.docx");

Load an Image from a Stream

Use case: Load image data that isn't stored on disk yet.

C#
1using var stream = File.OpenRead("chart.png");
2var image = doc.AddImage(stream);
3image.SetDimensions(300, 200, Units.pt);

Text Wrapping Around an Image

Use case: Float an image and let surrounding text wrap around it.

C#
1var image = doc.AddImage("chart.png");
2image.SetDimensions(200, 150, Units.pt);
3image.SetWrappingStyle(WrappingStyle.Square);
4image.SetDistanceFromText(6.0, Units.pt);

Export an Image to a File

Use case: Save an image extracted from a document.

C#
1using DOM.Enums;
2
3var image = doc.AddImage("logo.png");
4image.ExportToFile("copy.jpg", ImageType.jpg, 90);

Inline Image Inside a Paragraph

Use case: Insert a small icon in the middle of a sentence.

C#
1var p = doc.AddParagraph();
2p.AddText("Status: ");
3p.AddImage(new Image("ok.png")).SetDimensions(14, 14, Units.pt);
4p.AddText(" All systems operational.");

Frequently asked questions

Which image formats are supported?

PNG, JPEG, GIF, BMP, TIFF, EMF, WMF, WEBP (support depends on the target runtime for some formats). See ImageType for the full list.

How do I make an image flow with the text?

Use SetWrappingStyle(WrappingStyle.Square) (or another wrapping mode) plus SetDistanceFromText(...).

Can I place an image behind the text?

Yes — call SetBehindDocument(true) on the image.

VegaRiseVDocs.NET

Reset Password

Enter your email and we'll send you a link to reset your password.

Remember your password? Sign in