DynaPDF Manual - Page 488

Function Reference
Page 488 of 839
First, we must multiply the matrices ctm and tm with MulMatrix() as shown above and pass the
resulting matrix to GetScaleY() as described below; the return value is the scaling factor on the y-
axis. Finally, the font size must be multiplied with the scaling factor:
// Distance between two points
double CalcDistance(double x1, double y1, double x2, double y2)
{
double dx = x2-x1;
double dy = y2-y1;
return sqrt(dx*dx + dy*dy);
}
// Scaling factor of the y-axis
double GetScaleY(TCTM &M)
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 0.0;
double y2 = 1.0;
Transform(M, x1, y1);
Transform(M, x2, y2);
if (y1 > y2)
return -CalcDistance(x1, y1, x2, y2);
else
return CalcDistance(x1, y1, x2, y2);
}
TCTM
m = MulMatrix(stack.ctm, stack.tm); // User space matrix
double fs = stack.FontSize * GetScaleY(m);
// Real font size
How to calculate the rotation angle?
If you want to know whether the string is rotated then use the function TransRotation() to calculate
the rotation angle in radians. Note that this function requires again the pre-multiplied matrix in user
space.
double TransRotation(TCTM &M)
{
double x1 = 0.0; double x2 = 1.0;
double y1 = 0.0; double y2 = 0.0;
Transform(M, x1, y1);
Transform(M, x2, y2);
return atan2(y2-y1, x2-x1);
}
How to find and replace text in a page?
As mentioned in the previous sections text replacement or text search algorithms are not easy to
develop because many things must be considered to get suitable results. To make the development
easier DynaPDF is delivered with several example projects which are available in C++, Delphi, VB

Next topic: GetPageWidth