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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Resize photo to fit Textbox after Replace

Thread ID:





148227 Oct 10,2019 12:32 PM UTC Oct 11,2019 09:21 AM UTC WinForms 1
Tags: DocIO
Hugo Minoodt
Asked On October 10, 2019 12:32 PM UTC

I replace {PHOTO} in a document using this code:

Dim paragraph As WParagraph = New WParagraph(doc)
Dim pictureW As WPicture
Dim textBodyPart As TextBodyPart = New TextBodyPart(doc)

pictureW = CType(paragraph.AppendPicture(b, WPicture)

doc.Replace("{PHOTO}", textBodyPart, False, False)

The problem is need to solve is that when {PHOTO} is inside a Textbox, the photo needs to resize to fit the Textbox.

How can I do this?

Mohanaselvam  Jothi [Syncfusion]
Replied On October 11, 2019 09:21 AM UTC

Hi Hugo,

Thank you for contacting Syncfusion support.

We have prepared a sample application to resize the photo to fit within the textbox as per your requirement and it can be downloaded from the below link:

Note: Please find the template Word document in “Data” folder of above sample application.

In the above sample, we have done the following things:
  1. Loads the template Word document.
  2. Appends picture to the new textbody part.
  3. Finds the text where to place an image in Word document.
  4. Resizes the width and height of the picture based on size of textbox.
  5. Replaces a place holder text with the text body part (picture).
  6. Saves the Word document.

Please let us know if you have any other questions.

Mohanaselvam J


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