PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllDraws text bounded by a rectangle. If text does not fit in the box then text is cropped. To fit text in the box using wrapping call PDFPAGE_TextOutBox.
|
| HRESULT PDFPAGE_TextBox ( DOUBLE left, DOUBLE top, DOUBLE right, DOUBLE bottom, BSTR text, TxHorJust horizontalJustification, TxVertJust verticalJustification ) |
Parameters
left
X coordinate of the left-top corner of the bounding rectangle.
top
Y coordinate of the left-top corner of the bounding rectangle.
right
X coordinate of the right-bottom corner of the bounding rectangle.
bottom
Y coordinate of the right-bottom 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 procedure 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, with horizontal and vertical justification specified in horizontalJustification and verticalJustification parameters.
Analogue in new interface: IPDFDocument4::ShowTextAligned.
Example
Drawing text in the 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


