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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Object Model Changed for Image Paragraph

Thread ID:

Created:

Updated:

Platform:

Replies:

151360 Feb 7,2020 04:37 PM UTC Feb 10,2020 12:49 PM UTC Xamarin.Forms 1
loading
Tags: DocIO
Mario
Asked On February 7, 2020 04:37 PM UTC

Hi there..I used to be able to use this code to mail merge a document with pictures but the WordImageParagraph class no longer exists in 17.4.0.39. What has it changed to?



 //Opens the Word template document
            using (WordDocument document = new WordDocument(assembly.GetManifestResourceStream(resourceName), FormatType.Docx))
            {
                Dictionary<WParagraph, int> pictureFieldsData = new Dictionary<WParagraph, int>();

                var list = new List<WordImageParagraph>();

                document.MailMerge.MergeImageField += new MergeImageFieldEventHandler(
                    delegate (object sender, MergeImageFieldEventArgs args)
                    {
                        //Get the image from disk during Merge.
                        if (args.FieldName == "ClientSignature" || args.FieldName == "UserSignature")
                        {
                            if (args.FieldName == "ClientSignature" && this.Item?.Client.Signature == null)
                            {
                                args.ImageStream = new MemoryStream();
                                return;
                            }

                            if (args.FieldName == "UserSignature" && App.UserInfo?.Signature == null)
                            { 
                                args.ImageStream = new MemoryStream();
                                return;
                            }


                            args.ImageStream = args.FieldName == "ClientSignature" ?
                                new MemoryStream(this.Item?.Client.Signature) :
                                new MemoryStream(App.UserInfo.Signature);

                            WParagraph paragraph = args.CurrentMergeField.OwnerParagraph;

                            if (paragraph != null)
                            {
                                //had to change this code as we were getting duplicate OwnerParagraphs added to the dictionary
                                //pictureFieldsData.Add(paragraph, paragraph.Items.IndexOf(args.CurrentMergeField));
                                list.Add(new WordImageParagraph { Paragraph = paragraph, Index = paragraph.Items.IndexOf(args.CurrentMergeField) });
                            }
                        }
                        


                    });

                document.MailMerge.ExecuteGroup(this.GetMailMergeDataTable());

              

                foreach (var item in list)
                {
                    WParagraph paragraph = item.Paragraph as WParagraph;

                    //Fields are updated with pictures.
                    //Gets picture from the index of image field.
                    WPicture picture = paragraph.Items[item.Index] as WPicture;
                    if (picture != null)
                    {
                        //Changes the size of picture.
                        picture.Height = 40;
                        picture.Width = 65;
                    }
                }


                MemoryStream stream = new MemoryStream();

                //Saves the Word file to MemoryStream
                document.Save(stream, FormatType.Docx);

                return stream;
            }

Manikandan Ravichandran [Syncfusion]
Replied On February 10, 2020 12:49 PM UTC

Hi Mario,

Thank you for contacting Syncfusion.

We are unable to reproduce the mentioned issue at our end with given details. For your reference we have attached the sample which we have tried at our end to reproduce the mentioned issue.

Sample Link
https://www.syncfusion.com/downloads/support/forum/151360/ze/XamarinFormsApp1712152682

So, kindly provide us complete runnable sample and input document used at your end to reproduce the mentioned issue, so that we can proceed further to analyse and update you with the appropriate details.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran
 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon