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.

Insert Image at Specific X/Y Postion

Thread ID:

Created:

Updated:

Platform:

Replies:

128964 Feb 18,2017 06:31 AM Feb 21,2017 11:26 PM Windows Forms 6
loading
Tags: DocIO
Nilofer
Asked On February 18, 2017 06:31 AM

How do we insert Image at specific point lets say x,y Location.

Best Regards,

Sethumanikkam Yogendran [Syncfusion]
Replied On February 19, 2017 11:37 PM

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


Nilofer
Replied On February 20, 2017 12:22 AM

Thanks Sethumanikkam, I will check this 

Also how do we draw a line at specific x,y and later delete this line?

Best Regards,

Nilofer
Replied On February 20, 2017 04:06 AM

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


Hi, this is for a new document I guess I need to open a old document and put this image at x,y position.
In your case we need to create paragraphs and all which won't work in existing document,

Sethumanikkam Yogendran [Syncfusion]
Replied On February 21, 2017 01:12 AM

Hi Nilofer,

Thank you for your update.

We have prepared a sample to meet your requirement and in this sample, we have done the following things.

1. Loaded existing Word document using Essential DocIO.
2. Added image in specific (x, y) location.
3. Added line (shape) and delete it (if necessary) using helper method.
4. Saved modified Word document

Please find the sample from below link, and let us know if this helps you.
Sample link

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


Nilofer
Replied On February 21, 2017 02:56 AM

Thanks Sethumanikkam, Appreciate your support.

Best Regards,

Sethumanikkam Yogendran [Syncfusion]
Replied On February 21, 2017 11:26 PM

Hi Nilofer,

Thank you for your update.

We are happy to hear that the provided solution resolved your requirement. Please let us know if you need any further assistance on this. We will be happy to assist you as always.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


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.

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.

;