HorizontalPositionAnchor Enumeration |
Represents a horizontal position to which the parent object has been anchored in the document.
Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2025.2.13
Syntaxpublic enum HorizontalPositionAnchor
Public Enumeration HorizontalPositionAnchor
MembersMember name | Value | Description |
---|
Margin | 0 |
Specifies that the parent object shall be horizontally anchored to the text margins.
|
Page | 1 |
Specifies that the parent object shall be horizontally anchored to the page edge.
|
Column | 2 |
Specifies that the parent object shall be horizontally anchored to the text extents.
|
Character | 3 |
Specifies that the horizontal positioning shall be relative to the position
of the anchor within its text.
|
LeftMargin | 4 |
Specifies that the horizontal positioning shall be relative to the left margin of the page.
|
RightMargin | 5 |
Specifies that the horizontal positioning shall be relative to the right margin of the page.
|
InsideMargin | 6 |
Specifies that the horizontal positioning shall be relative to the inside margin
of the current page (the left margin on odd pages, right on even pages).
|
OutsideMargin | 7 |
Specifies that the horizontal positioning shall be relative to the outside margin
of the current page (the right margin on odd pages, left on even pages).
|
ExampleSee Developer Guide: How to work with shapes and geometry
How to work with shapes and geometry in C#
using System;
using System.IO;
using SautinSoft.Document;
using SautinSoft.Document.Drawing;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
Geometry();
}
public static void Geometry()
{
string pictPath = @"..\..\..\image1.jpg";
string documentPath = @"Geometry.docx";
DocumentCore dc = new DocumentCore();
Shape shp1 = new Shape(dc, Layout.Floating(
new HorizontalPosition(20f, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin),
new VerticalPosition(80f, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin),
new Size(100, 100)
));
shp1.Outline.Fill.SetSolid(new Color(53, 140, 203));
shp1.Outline.Width = 3;
shp1.Fill.SetSolid(Color.Orange);
shp1.Geometry.SetPreset(Figure.SmileyFace);
Shape shp2 = new Shape(dc, Layout.Floating(
new HorizontalPosition(85f, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin),
new VerticalPosition(80f, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin),
new Size(100, 100)
));
shp2.Outline.Fill.SetSolid(Color.Green);
shp2.Outline.Width = 2;
shp2.Fill.SetPicture(pictPath);
Size size = new Size(1, 1);
Point[] points = new Point[10];
double a = 0;
for (int i = 0; i < 10; ++i)
{
points[i] = new Point(0.5 + Math.Sin(a) * 0.5, 0.5 + Math.Cos(a) * 0.5);
a += 2 * Math.PI / 10;
}
shp2.Geometry.SetCustom().AddPath(size, points, true);
Shape shp3 = new Shape(dc, Layout.Floating(
new HorizontalPosition(150f, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin),
new VerticalPosition(80f, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin),
new Size(100, 100)
));
shp3.Outline.Fill.SetSolid(new Color(255,0,0));
shp3.Outline.Width = 2;
shp3.Fill.SetSolid(Color.Yellow);
CustomPath path = shp3.Geometry.SetCustom().AddPath(new Size(1, 1));
path.MoveTo(new Point(0, 0));
path.AddLine(new Point(0, 1));
path.AddLine(new Point(1, 1));
path.AddLine(new Point(1, 0));
path.ClosePath();
dc.Content.End.Insert(shp1.Content);
dc.Content.End.Insert(shp2.Content);
dc.Content.End.Insert(shp3.Content);
dc.Save(documentPath);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true });
}
}
}
How to work with shapes and geometry in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Imports SautinSoft.Document.Drawing
Module Sample
Sub Main()
Geometry()
End Sub
Sub Geometry()
Dim pictPath As String = "..\..\..\image1.jpg"
Dim documentPath As String = "Geometry.docx"
Dim dc As New DocumentCore()
Dim shp1 As New Shape(dc, Layout.Floating(New HorizontalPosition(20.0F, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin), New VerticalPosition(80.0F, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin), New Size(100, 100)))
shp1.Outline.Fill.SetSolid(New Color("358CCB"))
shp1.Outline.Width = 3
shp1.Fill.SetSolid(Color.Orange)
shp1.Geometry.SetPreset(Figure.SmileyFace)
Dim shp2 As New Shape(dc, Layout.Floating(New HorizontalPosition(85.0F, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin), New VerticalPosition(80.0F, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin), New Size(100, 100)))
shp2.Outline.Fill.SetSolid(Color.Green)
shp2.Outline.Width = 2
shp2.Fill.SetPicture(pictPath)
Dim size As New Size(1, 1)
Dim points(9) As Point
Dim a As Double = 0
For i As Integer = 0 To 9
points(i) = New Point(0.5 + Math.Sin(a) * 0.5, 0.5 + Math.Cos(a) * 0.5)
a += 2 * Math.PI / 10
Next i
shp2.Geometry.SetCustom().AddPath(size, points, True)
Dim shp3 As New Shape(dc, Layout.Floating(New HorizontalPosition(150.0F, LengthUnit.Millimeter, HorizontalPositionAnchor.LeftMargin), New VerticalPosition(80.0F, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin), New Size(100, 100)))
shp3.Outline.Fill.SetSolid(New Color(255, 0, 0))
shp3.Outline.Width = 2
shp3.Fill.SetSolid(Color.Yellow)
Dim path As CustomPath = shp3.Geometry.SetCustom().AddPath(New Size(1, 1))
path.MoveTo(New Point(0, 0))
path.AddLine(New Point(0, 1))
path.AddLine(New Point(1, 1))
path.AddLine(New Point(1, 0))
path.ClosePath()
dc.Content.End.Insert(shp1.Content)
dc.Content.End.Insert(shp2.Content)
dc.Content.End.Insert(shp3.Content)
dc.Save(documentPath)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True})
End Sub
End Module
See Also