RelativeHorizontalPosition enumeration

RelativeHorizontalPosition enumeration

Specifies to what the horizontal position of a shape or text frame is relative.

Members

NameDescription
MarginSpecifies that the horizontal positioning shall be relative to the page margins.
PageThe object is positioned relative to the left edge of the page.
ColumnThe object is positioned relative to the left side of the column.
CharacterThe object is positioned relative to the left side of the paragraph.
LeftMarginSpecifies that the horizontal positioning shall be relative to the left margin of the page.
RightMarginSpecifies that the horizontal positioning shall be relative to the right margin of the page.
InsideMarginSpecifies 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).
OutsideMarginSpecifies 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).
DefaultDefault value is RelativeHorizontalPosition.Column.

Examples

Shows how to insert a floating image to the center of a page.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
let shape = builder.insertImage(base.imageDir + "Logo.jpg");
shape.wrapType = aw.Drawing.WrapType.None;
shape.behindText = true;
shape.relativeHorizontalPosition = aw.Drawing.RelativeHorizontalPosition.Page;
shape.relativeVerticalPosition = aw.Drawing.RelativeVerticalPosition.Page;
shape.horizontalAlignment = aw.Drawing.HorizontalAlignment.Center;
shape.verticalAlignment = aw.Drawing.VerticalAlignment.Center;

doc.save(base.artifactsDir + "Image.CreateFloatingPageCenter.docx");

Shows how to insert an image, and use it as a watermark.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

// Insert the image into the header so that it will be visible on every page.
builder.moveToHeaderFooter(aw.HeaderFooterType.HeaderPrimary);
let shape = builder.insertImage(base.imageDir + "Transparent background logo.png");
shape.wrapType = aw.Drawing.WrapType.None;
shape.behindText = true;

// Place the image at the center of the page.
shape.relativeHorizontalPosition = aw.Drawing.RelativeHorizontalPosition.Page;
shape.relativeVerticalPosition = aw.Drawing.RelativeVerticalPosition.Page;
shape.left = (builder.pageSetup.pageWidth - shape.width) / 2;
shape.top = (builder.pageSetup.pageHeight - shape.height) / 2;

doc.save(base.artifactsDir + "DocumentBuilder.InsertWatermark.docx");

See Also