PDFPAGE_TextBox
IPDFDocument3 :: PDF page methods

See Also Example
Collapse All

This method draws text bounded by a rectangle. If the text does not fit in the box, it is cropped. To fit text in the box using wrapping, call PDFPAGE_TextOutBox.

Syntax

HRESULT PDFPAGE_TextBox (
DOUBLE left,
DOUBLE top,
DOUBLE right,
DOUBLE bottom,
BSTR text,
TxHorJust horizontalJustification,
TxVertJust verticalJustification
)
Parameters
left
X coordinate of the top-left corner of the bounding rectangle

top
Y coordinate of the top-left corner of the bounding rectangle

right
X coordinate of the bottom-right corner of the bounding rectangle

bottom
Y coordinate of the bottom-right corner of the bounding rectangle

text
Text to be displayed.

horizontalJustification
Horizontal justification.

verticalJustification
Vertical justification.

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

This method draws a text string (using the current font) inside an area bounded by a rectangle, with (left, top) and (right, bottom) coordinates for top-left and bottom-right corners, and with the horizontal and vertical justification specified in horizontalJustification and verticalJustification parameters.

Equivalent in new interface: IPDFDocument4::ShowTextAligned.

Example

Drawing Text in a Box

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.BeginDoc;
txt := 'Text in the box.'
PDF.PDFPAGE_SetActiveFont('Helvetica', false, false, false, false, 12.0, 0);

PDF.PDFPAGE_Rectangle(100, 100, 230, 130);
PDF.PDFPAGE_Stroke;
PDF.PDFPAGE_TextBox(100, 100, 230, 130, txt, hjLeft, vjUp);

PDF.PDFPAGE_Rectangle(100, 150, 230, 180);
PDF.PDFPAGE_Stroke;
PDF.PDFPAGE_TextBox(100, 150, 230, 180, txt, hjCenter, vjCenter);

PDF.PDFPAGE_Rectangle(100, 200, 230, 230);
PDF.PDFPAGE_Stroke;
PDF.PDFPAGE_TextBox(100, 200, 230, 230, txt, hjRight, vjDown);

PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->BeginDoc();
CString txt = "Text in the box.";
PDF->PDFPAGE_SetActiveFont("Helvetica", FALSE, FALSE, FALSE, FALSE, 12.0, 0);

PDF->PDFPAGE_Rectangle(100, 100, 230, 130);
PDF->PDFPAGE_Stroke();
PDF->PDFPAGE_TextBox(100, 100, 230, 130, txt, hjLeft, vjUp);

PDF->PDFPAGE_Rectangle(100, 150, 230, 180);
PDF->PDFPAGE_Stroke();
PDF->PDFPAGE_TextBox(100, 150, 230, 180, txt, hjCenter, vjCenter);

PDF->PDFPAGE_Rectangle(100, 200, 230, 230);
PDF->PDFPAGE_Stroke();
PDF->PDFPAGE_TextBox(100, 200, 230, 230, txt, hjRight, vjDown);

PDF->EndDoc();
C#
[copy to clipboard]
' PDF object is supposed to be created
PDF.BeginDoc();
string txt = "Text in the box.";
PDF.PDFPAGE_SetActiveFont("Helvetica", false, false, false, false, 12.0, 0);

PDF.PDFPAGE_Rectangle(100, 100, 230, 130);
PDF.PDFPAGE_Stroke();
PDF.PDFPAGE_TextBox(100, 100, 230, 130, txt, TxHorJust.hjLeft, TxVertJust.vjUp);

PDF.PDFPAGE_Rectangle(100, 150, 230, 180);
PDF.PDFPAGE_Stroke();
PDF.PDFPAGE_TextBox(100, 150, 230, 180, txt, TxHorJust.hjCenter, TxVertJust.vjCenter);

PDF.PDFPAGE_Rectangle(100, 200, 230, 230);
PDF.PDFPAGE_Stroke();
PDF.PDFPAGE_TextBox(100, 200, 230, 230, txt, TxHorJust.hjRight, TxVertJust.vjDown);

PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.BeginDoc
txt = "Text in the box."
PDF.PDFPAGE_SetActiveFont "Helvetica", False, False, False, False, 12.0, 0

PDF.PDFPAGE_Rectangle 100, 100, 230, 130
PDF.PDFPAGE_Stroke
PDF.PDFPAGE_TextBox 100, 100, 230, 130, txt, 0, 0

PDF.PDFPAGE_Rectangle 100, 150, 230, 180
PDF.PDFPAGE_Stroke
PDF.PDFPAGE_TextBox 100, 150, 230, 180, txt, 1, 1

PDF.PDFPAGE_Rectangle 100, 200, 230, 230
PDF.PDFPAGE_Stroke
PDF.PDFPAGE_TextBox 100, 200, 230, 230, txt, 2, 2

PDF.EndDoc

See Also

Reference