DynaPDF Manual - Page 447

Previous Page 446   Index   Next Page 448

Function Reference
Page 447 of 839
GetLastTextPosX, GetLastTextPosY
double pdfGetLastTextPosX/Y(
const PPDF* IPDF) // Instance pointer
The functions return the end position of the last drawn text. The returned y-coordinate is the
position of the text's baseline measured in bottom-up coordinates.
Return values:
If the function succeeds the return value is the x- or y-coordinate. This value can be negative
depending on the coordinate where the string was placed. If the function fails the return value is a
negative error code. An error code is smaller than -33554531.0.
Example 1 (Top Down Coordinates):
pdfSetPageCoords(PDF, pcTopDown);
double fontSize = 20.0;
pdfSetFont(PDF, "Times", fsItalic, fontSize, true, cp1252);
Because we use top down coordinates in this example we must transform
the returned y-coordinate to top down coordinates. To achieve this we
must subtract the value from the page height.
The coordinate origin of the text in top down coordinates is normally
the upper left corner. So, we must also subtract the font size because
the provided y-coordinate lies on the text’s baseline.
pdfWriteFTextEx(PDF, 50, 50.0, 200.0, -1.0, taLeft, "Some text that "
"ends on an unknown position...");
pdfSetFillColor(PDF, PDF_RED);
"We are behind the last text line");
Example 2 (Rotated text):
pdfSetPageCoords(PDF, pcTopDown);
pdfSetFont(PDF, "Times", fsItalic, 20.0, true, cp1252);
The coordinate origin that is passed to RotateCoords() is measured in
top down coordinates in this example. However, after the function was
called bottom-up coordinates are active. Because the calculated end
point is measured in bottom-up coordinates too we can directly use the
coordinates to place some text behind the previous string. This works
of course only if the rotated coordinate system is still active.
pdfRotateCoords(PDF, 30.0, 150.0, 350.0);
// Note that buttom-up coordinates are now active
pdfWriteFTextEx(PDF, 50, 50.0, 200.0, -1.0, taLeft, "Some rotated text "
"that ends on an unknown position...");

Previous topic: GetJavaScriptName, GetJPEGQuality, GetLanguage

Next topic: GetLaunchAction