Merge Image with DocIO

I want to merge images using DocIO

Following are the steps which were taken to merge images in Word

Following steps from this site:

 

https://smallbusiness.chron.com/merge-pictures-word-53827.html

 

  1. Open blank word document.

  2. Select Insert, Pictures

  3. Find Pictures and select both and select insert.

  4. Pictures come on two different pages.

  5. Click on each picture and select Format, Wrap Text, Square.

  6. Take 2nd picture and move up to first picture.

  7. Expand picture to cover entire borders.

  8. On picture, right click and Send to Back.

 

Result is attached.


How can it be done with DocIO?


Regards


Attachment: ImageMerge_99e2cb5f.zip

3 Replies

PK Prakash Kumar D Syncfusion Team July 26, 2018 11:25 AM UTC

Hi Mangesh, 
Thank you for contacting Syncfusion support. You can achieve your requirement by using the following code snippet. 
 
Code snippet: 
 
//Creates a new word document 
WordDocument wordDocument = new WordDocument(); 
 
//Adds new section to the document 
IWSection section = wordDocument.AddSection(); 
 
//Defines the pagesize 
section.PageSetup.PageSize = PageSize.Letter; 
section.PageSetup.Margins.All = 72; 
 
//Adds new paragraph to the section 
IWParagraph firstParagraph = section.AddParagraph(); 
IWPicture picture = firstParagraph.AppendPicture(Image.FromFile("..//..//Data//image1.jpeg")); 
 
//Sets the wrapping style for the image as Square 
picture.TextWrappingStyle = TextWrappingStyle.Square; 
 
//Sets the horizontal and vertical origin 
picture.HorizontalOrigin = HorizontalOrigin.Margin; 
picture.VerticalOrigin = VerticalOrigin.Paragraph; 
 
//Sets the horizontal alignment 
picture.HorizontalAlignment = ShapeHorizontalAlignment.Right; 
 
//Sets the vertical postion 
picture.VerticalPosition = 176.25f; 
picture = firstParagraph.AppendPicture(Image.FromFile("..//..//Data//image2.png")); 
 
//Sets the horizontal and vertical origin 
picture.HorizontalOrigin = HorizontalOrigin.Margin; 
picture.VerticalOrigin = VerticalOrigin.Paragraph; 
 
//Sets the horizontal alignment 
picture.HorizontalAlignment = ShapeHorizontalAlignment.Right; 
 
//Sets the wrapping style for the image as Square 
picture.TextWrappingStyle = TextWrappingStyle.Square; 
 
//Saving the word document 
wordDocument.Save("Sample_DocIO.docx", FormatType.Docx); 
 
Please let us know if you need further assistance. 
 
Regards,
Prakash Kumar
 



MH Mangesh Hirave replied to Prakash Kumar D July 26, 2018 10:24 PM UTC

Hi Mangesh, 
Thank you for contacting Syncfusion support. You can achieve your requirement by using the following code snippet. 
 
Code snippet: 
 
//Creates a new word document 
WordDocument wordDocument = new WordDocument(); 
 
//Adds new section to the document 
IWSection section = wordDocument.AddSection(); 
 
//Defines the pagesize 
section.PageSetup.PageSize = PageSize.Letter; 
section.PageSetup.Margins.All = 72; 
 
//Adds new paragraph to the section 
IWParagraph firstParagraph = section.AddParagraph(); 
IWPicture picture = firstParagraph.AppendPicture(Image.FromFile("..//..//Data//image1.jpeg")); 
 
//Sets the wrapping style for the image as Square 
picture.TextWrappingStyle = TextWrappingStyle.Square; 
 
//Sets the horizontal and vertical origin 
picture.HorizontalOrigin = HorizontalOrigin.Margin; 
picture.VerticalOrigin = VerticalOrigin.Paragraph; 
 
//Sets the horizontal alignment 
picture.HorizontalAlignment = ShapeHorizontalAlignment.Right; 
 
//Sets the vertical postion 
picture.VerticalPosition = 176.25f; 
picture = firstParagraph.AppendPicture(Image.FromFile("..//..//Data//image2.png")); 
 
//Sets the horizontal and vertical origin 
picture.HorizontalOrigin = HorizontalOrigin.Margin; 
picture.VerticalOrigin = VerticalOrigin.Paragraph; 
 
//Sets the horizontal alignment 
picture.HorizontalAlignment = ShapeHorizontalAlignment.Right; 
 
//Sets the wrapping style for the image as Square 
picture.TextWrappingStyle = TextWrappingStyle.Square; 
 
//Saving the word document 
wordDocument.Save("Sample_DocIO.docx", FormatType.Docx); 
 
Please let us know if you need further assistance. 
 
Regards,
Prakash Kumar
 


The code below did not work. I am looking to merge Image1 inside Image2 inside the gold borders. Please see sample.docx inside the zip file

Regards

Attachment: ImageMerge_d0e3e3a0.zip


PK Prakash Kumar D Syncfusion Team July 27, 2018 11:29 AM UTC

Hi Mangesh, 
 
Thank you for updating us. 
 
The given original image2 (inside the gold borders) doesn’t have transparent region with gold borders.  Hence, we have created transparent image by saving the image from your expected output document. 
We have also added code to set required size for both the images. Please find the modified sample from the below link.  
 
 
 
 
 
Regards, 
Prakash Kumar 


Loader.
Up arrow icon