Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
What is this page about?
This page explains how to position tables precisely within a document using layout and formatting options.
There are floating tables and inline tables:
Sometimes you need to position a table in a document in a certain way. To do this, you need to use the alignment tools and set the indents between the table and the surrounding text.
In this article, we will discuss what options Aspose.Words provides for positioning.
You can set the position of an inline table using the Aspose.Words API and the Alignment property. Thus, you can adjust the alignment of the table relative to the document page.
The following code example shows how to set the position of an inline table:
If the table text wrapping is set to Around, you can get the table’s horizontal and vertical alignment using the RelativeHorizontalAlignment and RelativeVerticalAlignment properties.
With other types of text wrapping, you can get inline table alignment using the Alignment property.
The following code example shows how to get the table’s alignment:
The position of a floating table is determined using the following properties:
The following code example shows how to get the position of a floating table:
Just like getting, you can set the position of a floating table using the same Aspose.Words API.
It is important to know that alignment and horizontal and vertical distance are combined properties and one can reset the other. For example, setting the RelativeHorizontalAlignment will reset the AbsoluteHorizontalDistance to its default value and vice versa. The same is true for the vertical arrangement.
The following code example shows how to set the position of a floating table:
Aspose.Words also provides an opportunity to find out the distances between tables and surrounding texts:
The following code example shows how to get the distance between a table and its surrounding text:
Q: How do I set the alignment of an inline table?
A: Use the Table.Alignment property. For example, Table.Alignment = TableAlignment.Center; aligns the table to the center of the page. The property works only for inline tables.
Q: How can I retrieve the horizontal and vertical alignment of a floating table?
A: Access the Table.RelativeHorizontalAlignment and Table.RelativeVerticalAlignment properties. These return values such as RelativeHorizontalAlignment.Page or RelativeVerticalAlignment.Margin, indicating how the floating table is positioned relative to its anchor.
Q: What properties are required to set the position of a floating table?
A: Set HorizontalAnchor, VerticalAnchor, AbsoluteHorizontalDistance, and AbsoluteVerticalDistance. You can also use RelativeHorizontalAlignment or RelativeVerticalAlignment. Note that changing an alignment property resets the corresponding absolute distance to its default.
Q: How can I control the distance between a table and the surrounding text?
A: Use the DistanceTop, DistanceBottom, DistanceLeft, and DistanceRight properties of the Table object. These properties specify the amount of space on each side of the table in points.
Q: What does the AllowOverlap property do for floating tables?
A: AllowOverlap determines whether the floating table may overlap other floating objects. Set Table.AllowOverlap = true; to permit overlapping, or false to prevent it, ensuring the layout respects other objects.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.