Insert Image Dynamically | Add Image From Byte Array in Table | LINQ Reporting using .NET

Hello!

I make a little Test-Project to test some of your features and use some of your Example Code. I use your Manager-Contracts Example List to show this in my Word-Document, which works. In your Example-List, you have a Property, which called “Photo”, but when I would like to use this byte-Array and display this as an image, the image could not be displayed.

My question is now, how can I display this image (byte.array) in for e.g. the first column, in which I display the “Client Name” and “Manager Name”?
When I try to display it, I get the following error:

System.InvalidOperationException: “Tag ‘image’ is not well-formed. Tag ‘image’ must be located within an image container.”

You can download my Test-Project, which included the Word-Document (Reporting engine template - Total.docx) and Image (Logo.jpg), through the following link:

Test-Project

Password is: Aspose

Thank you in advance!

Best Regards

Batiatos

@Batiatos

Unfortunately, we are unable to download your project. We suggest you please read the instructions mention in the following article about inserting image into document using LINQ Reporting engine.

https://docs.aspose.com/words/net/inserting-images-dynamically/

If you still face problem, please ZIP and attach your input Word document, image and code example here for testing. We will investigate the issue and provide you more information on it.

Hello and thank you for your answer!

I would like to add the image per data record in a table of the word template. In my example for each Contract I would like to show the image of the Manager.

Aspose_Test.zip (382.4 KB)

I use Visual Studio 2019 and a console application to test the features! In the “debug”-folder are my word file and the image, which i use. I convert this image as a byte-array.

My second question is: When I must use the “foreach” in a word template, like in my test application and when I must/should use the “TableStart” in a word template?

Thank you in advance!

Best Regards

Batiatos

@Batiatos

Please follow the below instructions to add the image tag into template document. These instructions are mentioned in the article shared in my previous post.

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.
<<image [image_expression]>>

We have modified the document and attached it with this post for your kind reference.
Reporting engine template - Total.docx (15.9 KB)

TableStart and TableEnd is used for mail merge. You need to use these tags when you are using mail merge with region.

Please read the following article.
https://docs.aspose.com/words/net/outputting-sequential-data/#working-with-table-row-data-bands

Now, it works! :slight_smile:

Thank you for your help!

@Batiatos

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Reporting engine template - Total.docx :grinning:

@Sami69 Do you have the similar problem? Please let us know if you need assistance.