iText 9.8.0 API
iText.Layout.Properties.Transform Class Reference

Represents a sequence of 2D transformations to be applied during rendering. More...

Classes

class   SingleTransform
  This class is used to store one transform function. More...
 

Public Member Functions

  Transform ()
  Creates a new Transform instance. More...
 
  Transform (float a, float b, float c, float d, UnitValue e, UnitValue f)
  Creates a new Transform instance. More...
 
  Transform (int length)
  Creates a new Transform instance. More...
 
virtual void  AddSingleTransform (Transform.SingleTransform singleTransform)
  Adds a SingleTransform in a list of single transforms to process later. More...
 
virtual iText.Layout.Properties.Transform  AddTransform (Transform.SingleTransform singleTransform)
  Adds a SingleTransform in a list of single transforms to process later. More...
 
virtual iText.Layout.Properties.Transform  Translate (float x, float y)
  Appends a translation transform by the given point-unit offsets. More...
 
virtual iText.Layout.Properties.Transform  Translate (UnitValue x, UnitValue y)
  Appends a translation transform by the given UnitValue offsets. More...
 
virtual iText.Layout.Properties.Transform  ScaleX (float scX)
  Appends a horizontal scaling transform. More...
 
virtual iText.Layout.Properties.Transform  ScaleY (float scY)
  Appends a vertical scaling transform. More...
 
virtual iText.Layout.Properties.Transform  SkewX (float skewAngleX)
  Appends a horizontal skewing (shearing) transform. More...
 
virtual iText.Layout.Properties.Transform  SkewY (float skewAngleY)
  Appends a vertical skewing (shearing) transform. More...
 
virtual iText.Layout.Properties.Transform  SimulateRotateX (float angle)
  Appends an orthographic 2D approximation of a 3D rotation around the X axis. More...
 
virtual iText.Layout.Properties.Transform  SimulateRotateY (float angle)
  Appends an orthographic 2D approximation of a 3D rotation around the Y axis. More...
 
virtual iText.Layout.Properties.Transform  Rotate (float angle)
  Appends a counter-clockwise rotation transform. More...
 
virtual iText.Layout.Properties.Transform  Rotate (float angle, float cx, float cy)
  Appends a counter-clockwise rotation transform around a point offset from the element's center by (cx, cy). More...
 
virtual iText.Layout.Properties.Transform  Rotate (float angle, UnitValue cx, UnitValue cy)
  Appends a counter-clockwise rotation transform around a pivot point specified as UnitValue offsets from the element's center. More...
 

Static Public Member Functions

static AffineTransform  GetAffineTransform (iText.Layout.Properties.Transform t, float width, float height)
  Converts the Transform instance, i.e. the list of SingleTransform instances, to the equivalent iText.Kernel.Geom.AffineTransform instance relatively to the available area, including resolving of percent values to point values. More...
 

Detailed Description

Represents a sequence of 2D transformations to be applied during rendering.

Represents a sequence of 2D transformations to be applied during rendering.

This class can be used to compose translations, scaling, skewing, rotations, and lightweight 2D approximations of 3D rotations. It is used both for CSS-derived transforms and for programmatically defined layout transformations.

Constructor & Destructor Documentation

◆ Transform() [1/3]

iText.Layout.Properties.Transform.Transform ( )
inline

Creates a new Transform instance.

◆ Transform() [2/3]

iText.Layout.Properties.Transform.Transform ( float  a,
float  b,
float  c,
float  d,
UnitValue  e,
UnitValue  f 
)
inline

Creates a new Transform instance.

Creates a new Transform instance.

Detailed explanation of [a b c d e f] parameters of transformation matrix can be found in iText.Kernel.Geom.Matrix documentation.

Parameters
a horizontal scaling
b vertical skewing
c horizontal skewing
d vertical scaling
e horizontal translation
f vertical translation

◆ Transform() [3/3]

iText.Layout.Properties.Transform.Transform ( int  length )
inline

Creates a new Transform instance.

Parameters
length the amount of SingleTransform instances that this Transform instant shall contain and be able to process

Member Function Documentation

◆ AddSingleTransform()

virtual void iText.Layout.Properties.Transform.AddSingleTransform ( Transform.SingleTransform  singleTransform )
inlinevirtual

Adds a SingleTransform in a list of single transforms to process later.

Parameters
singleTransform a SingleTransform instance

◆ AddTransform()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.AddTransform ( Transform.SingleTransform  singleTransform )
inlinevirtual

Adds a SingleTransform in a list of single transforms to process later.

Parameters
singleTransform a SingleTransform instance
Returns
this Transform instance

◆ GetAffineTransform()

static AffineTransform iText.Layout.Properties.Transform.GetAffineTransform ( iText.Layout.Properties.Transform  t,
float  width,
float  height 
)
inlinestatic

Converts the Transform instance, i.e. the list of SingleTransform instances, to the equivalent iText.Kernel.Geom.AffineTransform instance relatively to the available area, including resolving of percent values to point values.

Parameters
t a Transform instance to convert
width the width of available area, the point value of which is equivalent to 100% for percentage resolving
height the height of available area, the point value of which is equivalent to 100% for percentage resolving
Returns
resulting affine transformation instance, accumulated from Transform

◆ Rotate() [1/3]

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.Rotate ( float  angle )
inlinevirtual

Appends a counter-clockwise rotation transform.

Appends a counter-clockwise rotation transform.

The rotation maps to the affine matrix [cos θ, sin θ, -sin θ, cos θ, 0, 0] , where θ is the supplied angle in radians. A positive angle rotates counter-clockwise in the PDF coordinate system (Y-axis pointing upward).

Note: the renderer applies every Transform centered on the element's occupied area, so this effectively rotates around the center of the element, not around the element origin (0, 0).

To rotate around a point offset from the element's center use Rotate(float, float, float).

Parameters
angle the counter-clockwise rotation angle, in radians
Returns
this Transform instance

◆ Rotate() [2/3]

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.Rotate ( float  angle,
float  cx,
float  cy 
)
inlinevirtual

Appends a counter-clockwise rotation transform around a point offset from the element's center by (cx, cy).

Appends a counter-clockwise rotation transform around a point offset from the element's center by (cx, cy).

Because the renderer already centers the coordinate system on the element's occupied area before applying the transform, (cx, cy) are interpreted as offsets from that center. Passing (0, 0) is equivalent to calling Rotate(float).

A positive angle rotates counter-clockwise in the PDF coordinate system (Y-axis pointing upward).

Parameters
angle the counter-clockwise rotation angle, in radians
cx horizontal offset from the element's center to the pivot point, in points
cy vertical offset from the element's center to the pivot point, in points
Returns
this Transform instance

◆ Rotate() [3/3]

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.Rotate ( float  angle,
UnitValue  cx,
UnitValue  cy 
)
inlinevirtual

Appends a counter-clockwise rotation transform around a pivot point specified as UnitValue offsets from the element's center.

Appends a counter-clockwise rotation transform around a pivot point specified as UnitValue offsets from the element's center.

Both point and percentage UnitValue s are supported. Percentages for cx are resolved relative to the element's width and percentages for cy relative to its height at render time, consistent with how Translate(UnitValue, UnitValue) works.

Passing UnitValue.createPointValue(0) for both cx and cy is equivalent to calling Rotate(float). A positive angle rotates counter-clockwise in the PDF coordinate system (Y-axis pointing upward).

Parameters
angle the counter-clockwise rotation angle, in radians
cx horizontal offset from the element's center to the pivot point
cy vertical offset from the element's center to the pivot point
Returns
this Transform instance

◆ ScaleX()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.ScaleX ( float  scX )
inlinevirtual

Appends a horizontal scaling transform.

Appends a horizontal scaling transform.

The element is stretched or compressed along the X axis by the given factor. A value of 1 leaves the width unchanged, values greater than 1 widen the element, and values between 0 and 1 narrow it.

Passing 0 collapses the element to zero width, making it invisible. Passing a negative value flips the element horizontally and scales it by the absolute value of the factor.

Parameters
scX the horizontal scale factor
Returns
this Transform instance

◆ ScaleY()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.ScaleY ( float  scY )
inlinevirtual

Appends a vertical scaling transform.

Appends a vertical scaling transform.

The element is stretched or compressed along the Y axis by the given factor. A value of 1 leaves the height unchanged, values greater than 1 increase the height, and values between 0 and 1 reduce it.

Passing 0 collapses the element to zero height, making it invisible. Passing a negative value flips the element vertically and scales it by the absolute value of the factor.

Parameters
scY the vertical scale factor
Returns
this Transform instance

◆ SimulateRotateX()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.SimulateRotateX ( float  angle )
inlinevirtual

Appends an orthographic 2D approximation of a 3D rotation around the X axis.

Appends an orthographic 2D approximation of a 3D rotation around the X axis.

This simulation applies vertical foreshortening only, equivalent to scaling the Y axis by cos(angle) . Perspective distortion is not applied.

Parameters
angle the rotation angle around the X axis, in radians
Returns
this Transform instance

◆ SimulateRotateY()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.SimulateRotateY ( float  angle )
inlinevirtual

Appends an orthographic 2D approximation of a 3D rotation around the Y axis.

Appends an orthographic 2D approximation of a 3D rotation around the Y axis.

This simulation applies horizontal foreshortening only, equivalent to scaling the X axis by cos(angle) . Perspective distortion is not applied.

Parameters
angle the rotation angle around the Y axis, in radians
Returns
this Transform instance

◆ SkewX()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.SkewX ( float  skewAngleX )
inlinevirtual

Appends a horizontal skewing (shearing) transform.

Appends a horizontal skewing (shearing) transform.

Vertical lines are tilted by the angle given in radians, shifting X coordinates proportionally to their Y position. Equivalent to the CSS skewX() function.

Parameters
skewAngleX the skew angle, in radians
Returns
this Transform instance

◆ SkewY()

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.SkewY ( float  skewAngleY )
inlinevirtual

Appends a vertical skewing (shearing) transform.

Appends a vertical skewing (shearing) transform.

Horizontal lines are tilted by the angle given in radians, shifting Y coordinates proportionally to their X position. Equivalent to the CSS skewY() function.

Parameters
skewAngleY the skew angle, in radians
Returns
this Transform instance

◆ Translate() [1/2]

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.Translate ( float  x,
float  y 
)
inlinevirtual

Appends a translation transform by the given point-unit offsets.

Parameters
x the horizontal translation in points
y the vertical translation in points
Returns
this Transform instance

◆ Translate() [2/2]

virtual iText.Layout.Properties.Transform iText.Layout.Properties.Transform.Translate ( UnitValue  x,
UnitValue  y 
)
inlinevirtual

Appends a translation transform by the given UnitValue offsets.

Appends a translation transform by the given UnitValue offsets.

Both point and percentage values are supported; percentages are resolved relative to the width (for x ) and the height (for y ) of the available area at render time.

Parameters
x the horizontal translation as a UnitValue
y the vertical translation as a UnitValue
Returns
this Transform instance