Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
« »

Matching the image size with a text frame size

Blogged by Björn Meyer on September 20, 2007 and tagged with Samples.

I just noticed an interesting support request in our support department. The user's intention was to insert an image into a text frame and to readjust the horizontal image size in the case that the text frame is resized.

The Image.Size property is read-only and contains the original size of the image. Images can be scaled using the HorizontalScaling and VerticalScaling properties. The scaling factor can be adjusted in percent. To calculate the proportion between the original size and the new size of the text frame, we simply divide the new frame size by original image size.

private void adaptImageSize(TXTextControl.TextFrame Frame, TXTextControl.Image Image, Size NewSize)
{
Frame.Size = NewSize;
float zoomX = ((float)Frame.Size.Width / (float)Image.Size.Width);
Image.HorizontalScaling = (int)(zoomX * 100f);
}
« Prev:ASP.NET: Getting the client's .NET version
» Next:Centralize Your Documents

Comments

If you would like to comment on this blog entry, please post a comment.

External verification page for ISO 9000:2000 certificate
ISO 9001:2000
certified