Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 738

Previous Page 737   Index   Next Page 739

Function Reference
Page 738 of 750
Text formatting
WriteFText() can be used to output simple formatted text such as right aligned or justified text, but it
is also possible to use certain format tags to create a list or other specific formattings. It is also
possible to use a callback function to create multi-column text or other more complex formattings.
First, we want to see how the text alignment can be changed inside a text block. WriteFText()
supports 4 format tags which can be used to do this, we call these tags alignment tags.
Alignment tags
An alignment tag changes the text alignment in a text block. The base alignment that is used by the
function was already defined by the parameter Align, this base alignment can also be changed inside
the text by inserting an alignment tag. The following tags are available:
\le# // Left aligned text
\re# // Right aligned text
\ce# // Centred text
\ju# // Justified text
Like all format tags, an alignment tag begins with a backslash (character code 92) and ends with a
numbersign (character code 35).
It is not possible to use multiple alignments in one text line. When an alignment tag is found the
current line is closed and the cursor moves to the next line and continues with the new alignment.
char fText[] = "Left aligned text, this is left aligned text, this is "
"left aligned text...\\ju#\\FC[255]This is justified text, this is "
"justified text, this is justified text, this is justified text, this "
"is justified text, this is justified text, this is justified text, "
"this is justified text...\\re#\\FC[165536]This is right aligned text, "
"this is right aligned text, this is right aligned text..."
"\\le#\\FC[233512]Back to left aligned text, we go back to left "
"aligned text...";
pdfSetTextRect(pdf, 50, 50, 150, -1);
pdfWriteFText(pdf, taLeft, fText);
double height = pdfGetPageHeight(pdf) - pdfGetLastTextPosY(pdf) - 50;
pdfRectangle(pdf, 50, 50, 150, height, fmStroke);

Previous topic: Output rectangle

Next topic: Command tags