DynaPDF Manual - Page 466
Previous Page 465 Index Next Page 467

Function Reference
Page 466 of 860
GetLastTextPosX, GetLastTextPosY
Syntax:
double pdfGetLastTextPosX/Y(
const PPDF* IPDF) // Instance pointer
These functions return the end position of the last drawn text before applying coordinate
transformations. This avoids double coordinate transformations when drawing objects with to these
coordinates. If you need absolute coordinates call GetLastTextPosXAbs() / GetLastTextPosYAbs()
instead.
The y-coordinate is the position of the text's baseline measured in bottom-up coordinates.
Note that the reference point of WriteFText() is the baseline plus font size, independent of the
current coordinate system. In contrast, the reference point of WriteText() is the baseline if bottom up
coordinates are active and the baseline plus font size if top down coordinates are active (see
SetPageCoords() for further information).
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);
pdfAppend(PDF);
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);
pdfWriteText(PDF,
pdfGetLastTextPosX(PDF),
pdfGetPageHeight(PDF) - pdfGetLastTextPosY(PDF) - fontSize,
"We are behind the last text line");
pdfEndPage(PDF);
Example 2 (Rotated text):
pdfSetPageCoords(PDF, pcTopDown);
pdfAppend(PDF);
pdfSetFont(PDF, "Times", fsItalic, 20.0, true, cp1252);
/*
Previous topic: GetJavaScriptName, GetJPEGQuality, GetLanguage
Next topic: GetLastTextPosXAbs, GetLastTextPosYAbs