Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Position

The Position property exposed by the PositionContentElement abstract class is used for manipulating the position of elements.

You can find a diagram representing the structure in RadPdfProcessing here.

The position is represented by the IPosition interface which provides the following methods:

  • void Scale(double scaleX, double scaleY): Applies the specified scale.

  • void ScaleAt(double scaleX, double scaleY, double centerX, double centerY): Applies the specified scale about the specified coordinates.

  • void Rotate(double angle): Applies the specified rotation.

  • void RotateAt(double angle, double centerX, double centerY): Applies the specified rotation about the specified coordinates.

  • void Translate(double offsetX, double offsetY): Applies the specified translation.

  • void Clear(): Clears the position, restoring it to its initial state.

  • IPosition Clone(): Clones the position.

The IPosition interface exposes a Matrix property which represents the matrix constructed from the applied transformations.

IPosition interface is implemented by the following classes:

By default, PositionContentElements use MatrixPosition, whereas FixedContentEditor uses SimplePosition.

MatrixPosition

Each of the applied transformations is being appended to all the previously applied ones. When the Matrix property is calculated, the order of the applied transformations is the same as the order of the invocation of the transform methods.

The MatrixPosition class exposes a static Default property, which represents the default MatrixPosition. The default Matrix of the default MatrixPosition is the Identity matrix.

Example 1 shows how transformations can be appended.

Example 1: Trasform MatrixPosition

MatrixPosition matrixPosition = new MatrixPosition(); 
matrixPosition.Translate(20, 20); // Translates the position by (20, 20) 
matrixPosition.Translate(30, 30); // Translates the position by (30, 30). 

The resulting matrix position was translated both horizontally and vertically by 50.

SimplePosition

Each of the applied transformations overwrites the previous transformations of the same type. When the value of the Matrix property is being calculated, the order of the transformations is the following:

  1. Scale
  2. Rotate
  3. Translate

The SimplePosition class exposes a static Default property which represents the default SimplePosition.

Example 2 shows how transformations overwrite the previous transformations of the same type.

Example 2: Transform SimplePosition

SimplePosition simplePosition = new SimplePosition(); 
simplePosition.Translate(20, 20); // Translates the position by (20, 20). 
simplePosition.Translate(30, 30); // Translates the position by (30, 30) overwriting the previous translations. 

The resulting simple position was translated both horizontally and vertically by 30, because of the transformation overwriting.

See Also

In this article