Foxit PDF SDK 5.3

How can I rotate a text object around its center instead of the origin of coordinates?

Figure 1(a) shows the rotation of a text object around the origin of coordinates in Foxit PDF SDK. If we want to rotate a text object around its center as shown in Figure 1(b), a set of complex transformations are needed. The complete transformation process is shown in Figure 2. First, translate the center of the text object to the origin of the coordinates. The translation vector is (-Cx,-Cy), as shown in Figure 2(b). Second, rotate the text object around the origin of coordinates with angle , as shown in Figure 2(c). Finally, translate the text object by using vector (Cx,Cy). The red text is the result as shown in Figure 2(d).

Figure 1: Rotation of a text object

Figure 2: Complete transformation process of rotating a text object around its center

The complex transformation matrix is made up of two translation matrices and a rotation matrix.
The homogeneous coordinates in PDF Reference are used for coordinate representation. As a result,
the complex transformation matrix is calculated by the following formula.

Once the complex transformation matrix is obtained, we can call the following functions to transform the text object.

FSCRT_MATRIX textmatrix = { , , −, , , };
ret = FSPDF_PageObject_SetMatrix(page, atuoTextObj.GetObject(), &textmatrix);

Note: This article refers to a deprecated version of a Foxit Product. If you are still using Foxit PDF SDK 5.3 or older, please refer to your download package documents for Developer Guide and API Reference.

Get a trial version of the new Foxit PDF SDK and see our latest generation SDK’s brand new features!

Updated on March 26, 2017

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: