Images can be inserted by using tags similar to text. The formatting depends upon the ImageTextWrapping property of the replacement item. Example:
C# | |
---|---|
//To run this example code, create a word document called TextWrappingSourceDocumentation.docx with the text [Image] in the document WordReportsGenerator generator = new WordReportsGenerator(); //Trial Mode //WordReportsGenerator generator = new WordReportsGenerator("place user name here", "place license key here"); //License Mode const string sourceDocumentPath = @"Test Documents\TextWrappingSourceDocumentation.docx"; const string outputDocumentPath = "ImageDocumentationTest.docx"; const string imagePath = @"Test Documents\KellermanSoftwareImage.png"; Dictionary<string, ReplacementItem> replacement = new Dictionary<string, ReplacementItem> { { "[Image]", new ReplacementItem { Value = Image.FromFile(imagePath), ImageTextWrapping = TextWrapping.Square } } }; generator.GenerateWordReport(sourceDocumentPath, outputDocumentPath, replacement); |
VB.NET | |
---|---|
'To run this example code, create a word document called TextWrappingSourceDocumentation.docx with the text [Image] in the document Dim generator As New WordReportsGenerator() 'Trial Mode 'WordReportsGenerator generator = new WordReportsGenerator("place user name here", "place license key here"); //License Mode Const sourceDocumentPath As String = "Test Documents\TextWrappingSourceDocumentation.docx" Const outputDocumentPath As String = "ImageDocumentationTest.docx" Const imagePath As String = "Test Documents\KellermanSoftwareImage.png" Dim replacement As New Dictionary(Of String, ReplacementItem)() From {{ "[Image]", New ReplacementItem With {.Value = Image.FromFile(imagePath), .ImageTextWrapping = TextWrapping.Square} }} generator.GenerateWordReport(sourceDocumentPath, outputDocumentPath, replacement) |