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:

https://www.pdftron.com/pdfnet/docs/PDFNetC/d5/d15/classpdftron_1_1_p_d_f_1_1_element.html#ae2b38a976bb5c3b5ea8adc6116af5443

You may want to see other examples for rotated text:

https://groups.google.com/forum/#!searchin/pdfnet-sdk/rotated$20text