//Creates a new Word document WordDocument document = new WordDocument(); //Adds new section to the document IWSection section = document.AddSection(); //Adds new paragraph to the section IWParagraph paragraph = section.AddParagraph(); paragraph.AppendText("This paragraph has picture. "); //Appends new picture to the paragraph IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png")); //Sets text wrapping style – When the wrapping style is inline, the images are not absolutely positioned. //It is added next to the textrange. picture.TextWrappingStyle = TextWrappingStyle.Square; //Sets horizontal and vertical origin picture.HorizontalOrigin = HorizontalOrigin.Page; picture.VerticalOrigin = VerticalOrigin.Paragraph; //Sets width and height for the paragraph picture.Width = 150; picture.Height = 100; //Sets horizontal and vertical position for the picture picture.HorizontalPosition = 200; picture.VerticalPosition = 150; picture.Name = "PictureName"; //Sets horizontal and vertical alignments picture.HorizontalAlignment = ShapeHorizontalAlignment.Center; picture.VerticalAlignment = ShapeVerticalAlignment.Bottom; //Saves the Word document document.Save("Sample.docx", FormatType.Docx); //Closes the document document.Close(); |
Hi Nilofer,
Thank you for contacting Syncfusion support.
You can insert Image at specific position (Absolute positioned images) in Word document by setting value of “HorizontalPosition” and “VerticalPosition” for the picture using Essential DocIO.
Please refer below code example from our UG link Working with Images.
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("This paragraph has picture. ");
//Appends new picture to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Sets text wrapping style – When the wrapping style is inline, the images are not absolutely positioned.
//It is added next to the textrange.
picture.TextWrappingStyle = TextWrappingStyle.Square;
//Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page;
picture.VerticalOrigin = VerticalOrigin.Paragraph;
//Sets width and height for the paragraph
picture.Width = 150;
picture.Height = 100;
//Sets horizontal and vertical position for the picture
picture.HorizontalPosition = 200;
picture.VerticalPosition = 150;
picture.Name = "PictureName";
//Sets horizontal and vertical alignments
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
picture.VerticalAlignment = ShapeVerticalAlignment.Bottom;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
Please let us know if you have any other questions.
Regards,
Sethumanikkam.Y