Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
ODF .NET
>
Tutorial
> Insert image
The following example shows you how to insert an image.
See screenshot
.
C# example
using System; using Independentsoft.Odf; using Independentsoft.Odf.Styles; using Independentsoft.Odf.Drawing; namespace Sample { class Program { static void Main(string[] args) { TextDocument doc = new TextDocument(); Image image1 = new Image("c:\\image.gif"); Frame frame1 = new Frame(); frame1.Width = new Size(6.67, Unit.Inch); //640 pixels frame1.Height = new Size(5, Unit.Inch); //480 pixels frame1.Add(image1); Paragraph paragraph1 = new Paragraph(); paragraph1.Add("Below is an image:"); Paragraph paragraph2 = new Paragraph(); paragraph2.Add(frame1); doc.Body.Add(paragraph1); doc.Body.Add(paragraph2); doc.Save("c:\\test.odt"); } } }
VB example
Imports System Imports Independentsoft.Odf Imports Independentsoft.Odf.Styles Imports Independentsoft.Odf.Drawing Module Module1 Sub Main(ByVal args() As String) Dim doc As TextDocument = New TextDocument Dim image1 As Image = New Image("c:\image.gif") Dim frame1 As Frame = New Frame frame1.Width = New Size(6.67, Unit.Inch) '640 pixels frame1.Height = New Size(5, Unit.Inch) '480 pixels frame1.Add(image1) Dim paragraph1 As Paragraph = New Paragraph paragraph1.Add("Below is an image:") Dim paragraph2 As Paragraph = New Paragraph paragraph2.Add(frame1) doc.Body.Add(paragraph1) doc.Body.Add(paragraph2) doc.Save("c:\test.odt", True) End Sub End Module