How to Insert Image Dynamically using .NET | LINQ Reporting

Hi,
I want to use image tag : <<image [image_expression]>>

but I don’t understand how to use it.

in my word template I have :

<< image [CoutEtChargeImage]>>

and in my C# program I have

var test = Image.Load(@“C:\Users\test\Pictures\18102018-_B5A9178.jpg”);
CoutEtChargeImage = test

And I use it with 
//initialising a doc
Document doc = new Document(templateFilePath);

// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.BuildReport(doc, this.DocumentData, "DocumentData");

But I always have this message
“details”:"System.InvalidOperationException: Tag ‘image’ is not well-formed. Tag ‘image’ must be located within an image container.

@Got

Please insert the image tag in the textbox to avoid this issue.

You can insert images to your reports dynamically using image tags. To declare a dynamically inserted image within your template, do the following steps:

  1. Add a textbox to your template at the place where you want an image to be inserted.
  2. Set common image attributes such as frame, size, and others for the textbox, making the textbox look like a blank inserted image.
  3. Specify an image tag within the textbox using the following syntax.

@tahir.manzoor

Yes I read it : “Please insert the image tag in the textbox to avoid this issue.”

But what does it mean ?

Can you put an example in this post please ? What is the good syntax ?

@Got

Please check the attached template document and following code example to get the desired output.

image linq.zip (11.4 KB)

Document doc = new Document(MyDir + "image linq.docx");

ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.BuildReport(doc, MyDir + @"in html.png", "CoutEtChargeImage");
doc.Save(MyDir + "output.docx");

@tahir.manzoor

Top ! Thank you so much ! :+1:

I didn’t realize it was so easy :rofl:

A post was split to a new topic: How to Insert Image Dynamically using .NET | LINQ Reporting Engine