We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ImageMerge problem

Thread ID:

Created:

Updated:

Platform:

Replies:

74221 Jun 3,2008 10:20 PM UTC Jun 4,2008 04:48 AM UTC Windows Forms 1
loading
Tags: DocIO
Administrator [Syncfusion]
Asked On June 3, 2008 10:20 PM UTC

I am in trouble with mail merging images. There is no problem with images form database. But when I am using the code below the mailmerge causes an "ArgumentException" exception.

DataTable dt2 = new DataTable(); dt2.Columns.Add("Photo1",typeof(System.Byte[]));
dt2.Columns.Add("Photo2",typeof(System.Byte[]));
dt2.TableName = "Photos";
DataRow dr2;
dr2 = dt2.NewRow();
FileStream fs = new FileStream("1.gif",FileMode.Open);
BinaryReader br = new BinaryReader(fs);
dr2["Photo1"] = br.ReadBytes((int)br.BaseStream.Length));
dr2["Photo2"] = br.ReadBytes((int)br.BaseStream.Length));
br = null;
fs.Close();
fs = null;
dt2.Rows.Add(dr2);

document.MailMerge.ExecuteGroup(dt2);

The i have configured merge fields in word document like in your emloyeesreport example.
where is the problem ? cany ou give me an advice about merging an external image form hdd to the merge field (Image:Photo1) of word document template.

Thank you



Bhuvaneswari P [Syncfusion]
Replied On June 4, 2008 04:48 AM UTC

Hi Lokelse,

Thank you for your interest in SYncfusion products.

I am able to reproduce the issue. This is due to the image is not converted to bytes properly. Please refer the below code snippet to do so:

[C#]

FileStream fs = new FileStream(@"..\..\Nature.jpg",FileMode.Open);
byte[] inByte = new byte[fs.Length];
fs.Read(inByte, 0, inByte.Length);
dr2["Photo1"] = inByte;
dr2["Photo2"] = inByte;

Here is the sample for your reference:

http://websamples.syncfusion.com/samples/DocIO.Windows/F74221/main.htm


Please try this and let us know if this helps you.

Best Regards,
Bhuvana


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;