Issue with text rotation

I have issues with text when the page is rotated. Exported as Landscape pdf.

Below is the code that i apply for other elements like Line, Rect and it works fine.
currPageRotation = page.GetRotation();

pdftron::Common::Matrix2D rotMtx(currPageRotation * DEG2RAD); //Note that i have a rotation angle of 270

For elements i multiply page rotation matrix with ctm,

pdftron::Common::Matrix2D ctm = path.GetCTM();
ctm *= pdftron::Common::Matrix2D::RotationMatrix( currPageRotation * DEG2RAD );

After multiplying all points with ctm, i see that the rotation is fine and i see the elements in right place.

But when i apply the rotation matrix to text it does not rotate properly. Below is the code.

pdftron::Common::Matrix2D text_mtx = element.GetTextMatrix();
text_mtx *= rotMtx;
pdftron::Common::Matrix2D ctm = element.GetCTM();
ctm *= rotMtx;

pdftron::Common::Matrix2D mtx = ctm * text_mtx;

I then multiply the resultant mtx with the character positioning information.

for (pdftron::PDF::CharIterator itr = element.GetCharIterator(); itr.HasNext(); itr.Next())
char_code = itr.Current().char_code;
charBuffer += string(1,char_code);

insertionPointX = itr.Current().x;
insertionPointY = itr.Current().y;
mtx.Mult(insertionPointX, insertionPointY);


It appears you are missing a call to Element.SetTextMatrix:

You may want to see other examples for rotated text:!searchin/pdfnet-sdk/rotated$20text