# Getting the Absolute Position of Anchored Objects

> TX Text Control offers multiple Add overloads in the FrameBase class for positioning TextFrames, Images, BarcodeFrames, and ChartFrames. Anchored objects return relative coordinates, so calculating absolute position requires combining the TextChar bounds with the ScrollLocation offset.

- **Author:** Bjoern Meyer
- **Published:** 2014-04-04
- **Modified:** 2026-03-05
- **Description:** TX Text Control offers multiple Add overloads in the FrameBase class for positioning TextFrames, Images, BarcodeFrames, and ChartFrames. Anchored objects return relative coordinates, so calculating absolute position requires combining the TextChar bounds with the ScrollLocation offset.
- **3 min read** (407 words)
- **Tags:**
  - Tutorial
- **Web URL:** https://www.textcontrol.com/blog/2014/04/04/getting-the-absolute-position-of-anchored-objects/
- **LLMs URL:** https://www.textcontrol.com/blog/2014/04/04/getting-the-absolute-position-of-anchored-objects/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2014/04/04/getting-the-absolute-position-of-anchored-objects/llms-full.txt

---

[TextFrames](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.textframe.class.htm), [Images](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.image.class.htm), [BarcodeFrames](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.datavisualization.barcodeframe.class.htm) and [ChartFrames](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.datavisualization.chartframe.class.htm) provide different ways to position those objects in the document. All objects are positioned in the same way as they are inherited from the base class [FrameBase](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.framebase.class.htm).

Based on TextFrames, let's have a look at the various positioning options:

```
public bool Add(TextFrame textFrame, int textPosition);

public bool Add(TextFrame textFrame,
    int page,
    System.Drawing.Point location,
    TextFrameInsertionMode insertionMode);

public bool Add(TextFrame textFrame,
    HorizontalAlignment alignment,
    int textPosition,
    TextFrameInsertionMode insertionMode);

public bool Add(TextFrame textFrame,
    System.Drawing.Point location,
    int textPosition,
    TextFrameInsertionMode insertionMode);
```

The first overload inserts a TextFrame at a specific text position and the absolute location can be easily obtained using the [TextChar](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.textchar.class.htm) class or the [InputPositon](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.inputposition.class.htm). The second method inserts the TextFrame at a fixed position on a page and the [Location](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.framebase.location.property.htm) property of the TextFrame returns the absolute position automatically.

Getting the absolute position of TextFrames that are inserted using the last two methods is a little tricky, but easily solvable with TextControl's flexible API. The following method returns the absolute position of a TextFrame that is anchored to a text position.

```
private Rectangle GetAbsolutePositionOfAnchoredTextFrame(TextFrame TextFrame)
{
    Graphics g = this.CreateGraphics();
    int iDPIFactor = (int)(1440 / g.DpiX);

    Rectangle rectAbsolutePosition = new Rectangle();

    if (textControl1.TextChars[frame.TextPosition] == null)
        throw new Exception("Text position doesn\'t exist");

    Rectangle rectAnchorOffset =
        textControl1.TextChars[frame.TextPosition].Bounds;

    rectAbsolutePosition.X = (frame.Location.X +
        rectAnchorOffset.X -
        textControl1.ScrollLocation.X) / iDPIFactor;

    rectAbsolutePosition.Y = (frame.Location.Y +
        rectAnchorOffset.Y -
        textControl1.ScrollLocation.Y) / iDPIFactor;

    rectAbsolutePosition.Width = frame.Size.Width / iDPIFactor;
    rectAbsolutePosition.Height = frame.Size.Height / iDPIFactor;

    return rectAbsolutePosition;
}
```

Anchored objects return the relative *Location* to the anchor position. This location of the anchor position can be obtained using the TextChar class:

```
Rectangle rectAnchorOffset =
textControl1.TextChars[frame.TextPosition].Bounds;
```

Additionally, the current ScrollLocation must be included in the calculation. The *iDPIFactor* is used to convert Twips to the required 1/100 inch that are used in .NET Windows Forms.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Windows Forms Tutorial: Create Your First Windows Forms C# Application](https://www.textcontrol.com/blog/2024/08/26/windows-forms-tutorial-create-your-first-windows-forms-csharp-application/llms.txt)
- [How to Mail Merge MS Word DOCX Documents in ASP.NET Core C#](https://www.textcontrol.com/blog/2023/10/16/how-to-mail-merge-ms-word-docx-documents-in-aspnet-core-csharp/llms.txt)
- [Creating an Angular Document Editor Application with a Node.js WebSocket Server](https://www.textcontrol.com/blog/2023/08/24/creating-an-angular-document-editor-application-with-a-nodejs-websocket-server/llms.txt)
- [Adding SVG Watermarks to Documents](https://www.textcontrol.com/blog/2022/01/28/adding-svg-watermarks-to-documents/llms.txt)
- [Using MailMerge in ASP.NET Core 6 Web Applications](https://www.textcontrol.com/blog/2022/01/27/using-mailmerge-in-aspnet-core-6-web-applications/llms.txt)
- [DocumentViewer for React Prerelease](https://www.textcontrol.com/blog/2020/10/27/document-viewer-for-react-prerelease/llms.txt)
- [New DocumentViewer Signature Tutorial Sample](https://www.textcontrol.com/blog/2020/08/18/new-documentviewer-signature-tutorial-sample/llms.txt)
- [Creating an ASP.NET MVC DocumentViewer Application With Razor](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-documentviewer-application-with-razor/llms.txt)
- [Creating Your First Windows Forms Application with C#](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-windows-forms-application-with-csharp/llms.txt)
- [Creating Your First WPF Application](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-wpf-application/llms.txt)
- [Creating a WPF Ribbon Application](https://www.textcontrol.com/blog/2020/01/01/creating-a-wpf-ribbon-application/llms.txt)
- [Integrate Document Editing into any HTML Client using the HTML Widget](https://www.textcontrol.com/blog/2020/01/01/integrate-document-editing/llms.txt)
- [Creating an ASP.NET MVC Application With Razor](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-application-with-razor/llms.txt)
- [Creating A Windows Forms Ribbon Application](https://www.textcontrol.com/blog/2020/01/01/creating-a-windows-forms-ribbon-application/llms.txt)
- [Creating Your First ASP.NET Reporting Application](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-aspnet-reporting-application/llms.txt)
- [Creating an ASP.NET Web Forms AJAX Application](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-web-forms-ajax-application/llms.txt)
- [Creating a WebSocket Server Project with Node.js](https://www.textcontrol.com/blog/2020/01/01/creating-a-websocket-server-project-with-nodejs/llms.txt)
- [Creating an Angular Document Editor Application](https://www.textcontrol.com/blog/2020/01/01/creating-an-angular-document-editor-application/llms.txt)
- [ReportingCloud .NET Core Quickstart Tutorial](https://www.textcontrol.com/blog/2019/07/24/reportingcloud-dotnet-core-quickstart-tutorial/llms.txt)
- [Document Permissions and Password Encryption](https://www.textcontrol.com/blog/2019/07/05/document-permissions-and-password-encryption/llms.txt)
- [New Online Sample: Build your First Report](https://www.textcontrol.com/blog/2019/07/03/build-your-first-report/llms.txt)
- [Create your First Document with ReportingCloud](https://www.textcontrol.com/blog/2019/02/19/create-your-first-document-with-reportingcloud/llms.txt)
- [MailMerge: Starting Each Merge Block on a New Page](https://www.textcontrol.com/blog/2016/09/09/mailmerge-starting-each-merge-block-on-a-new-page/llms.txt)
- [Windows Forms and WPF: End a List on Return when Line is Empty](https://www.textcontrol.com/blog/2016/08/26/windows-forms-and-wpf-end-a-list-on-return-when-line-is-empty/llms.txt)
- [Using IFormattedText Objects to Access Elements Across All TextParts in a Document](https://www.textcontrol.com/blog/2016/08/25/using-iformattedtext-objects-to-access-elements-across-all-textparts-in-a-document/llms.txt)
