Skip to content

Commit 3817407

Browse files
Samuel Huylebroeckyulian-gaponenko
authored andcommitted
Add convenience method for setting textmatrix
Add convenience method taking an AffineTransform in PdfCanvas Autoported commit. Original commit hash: [050c577863]
1 parent 66a442b commit 3817407

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

itext/itext.kernel/itext/kernel/pdf/canvas/PdfCanvas.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public virtual iText.Kernel.Pdf.Canvas.PdfCanvas RestoreState() {
345345
/// Concatenates the 2x3 affine transformation matrix to the current matrix
346346
/// in the content stream managed by this Canvas.
347347
/// Contrast with
348-
/// <see cref="SetTextMatrix(float, float)"/>
348+
/// <see cref="SetTextMatrix(iText.Kernel.Geom.AffineTransform)"/>
349349
/// </remarks>
350350
/// <param name="a">operand 1,1 in the matrix.</param>
351351
/// <param name="b">operand 1,2 in the matrix.</param>
@@ -595,6 +595,19 @@ public virtual iText.Kernel.Pdf.Canvas.PdfCanvas SetTextMatrix(float a, float b,
595595
return this;
596596
}
597597

598+
/// <summary>Replaces the text matrix.</summary>
599+
/// <remarks>
600+
/// Replaces the text matrix. Contrast with
601+
/// <see cref="ConcatMatrix(iText.Kernel.Pdf.PdfArray)"/>
602+
/// </remarks>
603+
/// <param name="transform">new textmatrix as transformation</param>
604+
/// <returns>current canvas</returns>
605+
public virtual iText.Kernel.Pdf.Canvas.PdfCanvas SetTextMatrix(AffineTransform transform) {
606+
float[] matrix = new float[6];
607+
transform.GetMatrix(matrix);
608+
return SetTextMatrix(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
609+
}
610+
598611
/// <summary>Changes the text matrix.</summary>
599612
/// <param name="x">operand 3,1 in the matrix.</param>
600613
/// <param name="y">operand 3,2 in the matrix.</param>

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
65869521f5572566f566be81ff453c91a286dda1
1+
050c57786373e5fe03f605d42a1ee4b1320d3233

0 commit comments

Comments
 (0)