DynaPDF Manual - Page 435

Previous Page 434   Index   Next Page 436

Function Reference
Page 435 of 818
GetLastTextPosX, GetLastTextPosY
Syntax:
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);
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);
/*
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.
*/
pdfSaveGraphicState(PDF);
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


Start Chat