formatting.txt
5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
Formatting
***************
Fonts
---------------
Size, Font family, Font color, Background color
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To format text, you can use the ``PHPRtfLite_Font``.
Example sets size to 12pt, font family to Arial, font color to red, and background color to blue:
.. code-block:: php
<?php
// some bootstraping here
$section = $rtf->addSection();
$font = new PHPRtfLite_Font(12, 'Arial', '#FF0000', '#0000FF');
$section->writeText('Lorem ipsum', $font);
Text formatting
~~~~~~~~~~~~~~~
.. code-block:: php
<?php
// some bootstraping here
$section = $rtf->addSection();
$font = new PHPRtfLite_Font();
$font->setBold(); // bold font
$font->setItalic(); // italic font
$font->setUnderline(); // underline font
$font->setStriked(); // strike text
$font->setDoubleStriked(); // double strike text
$section->writeText('Lorem ipsum', $font);
HTML-Tags as text formatting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can use HTML-Tags in your text to format text:
.. code-block:: php
<?php
// some bootstraping here
$section = $rtf->addSection();
// text will be displayed as bold
$section->writeText('<strong>text</strong>');
$section->writeText('<b>text</b>');
// text will be displayed as italic
$section->writeText('<em>text</em>');
$section->writeText('<i>text</i>');
// text will be displayed as underlined
$section->writeText('<u>text</u>');
// text will start with a bullet
$section->writeText('<bullet> text');
// text will have a line break after
$section->writeText('text<br>');
// text will have a horizontal rule after
$section->writeText('text<hr>');
// tabulator will be displayed between text
$section->writeText('text<tab>text');
// will display section number before "hello world"
$section->writeText('<sectnum> hello world');
// will display page number before "hello world"
$section->writeText('<pagenum> hello world');
Text animation
~~~~~~~~~~~~~~
Class constants for text animation:
- ``ANIMATE_LAS_VEGAS_LIGHTS``
- ``ANIMATE_BLINKING_BACKGROUND``
- ``ANIMATE_SPARKLE_TEXT``
- ``ANIMATE_MARCHING_BLACK_ANTS``
- ``ANIMATE_MARCHING_RED_ANTS``
- ``ANIMATE_SHIMMER``
.. code-block:: php
<?php
// some bootstraping here
$section = $rtf->addSection();
$font = new PHPRtfLite_Font();
// text with marching black ants around
$font->setAnimation(PHPRtfLite_Font::ANIMATE_MARCHING_BLACK_ANTS);
$section->writeText('Lorem ipsum', $font);
Paragraph formatting
--------------------
Text alignment
~~~~~~~~~~~~~~~~~~~~
Class constants for text alignment:
- ``TEXT_ALIGN_LEFT``
- ``TEXT_ALIGN_RIGHT``
- ``TEXT_ALIGN_CENTER``
- ``TEXT_ALIGN_JUSTIFY``
.. code-block:: php
<?php
// some bootstraping here
$section = $rtf->addSection();
// centered text
$parFormat = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER);
$section->writeText('Lorem ipsum', null, $parFormat);
Paragraph indention
~~~~~~~~~~~~~~~~~~~~
First line indention:
.. code-block:: php
<?php
// some bootstraping here
$section = $rtf->addSection();
$parFormat = new PHPRtfLite_ParFormat();
// first line of paragraph will be indented by 1cm
$parFormat->setIndentFirstLine(1);
$section->writeText('Lorem ipsum', null, $parFormat);
Indent the whole paragraph left or/and right:
.. code-block:: php
<?php
// some bootstraping here
$parFormat = new PHPRtfLite_ParFormat();
// paragraph will be indented by 1cm from the left and right
$parFormat->setIndentLeft(1);
$parFormat->setIndentRight(1);
Space between paragraphs
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: php
<?php
// some bootstraping here
$parFormat = new PHPRtfLite_ParFormat();
// spaces in lines after the paragraph
$parFormat->setSpaceAfter(1);
// spaces in lines before the paragraph
$parFormat->setSpaceBefore(1);
Space between lines
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: php
<?php
// some bootstraping here
$parFormat = new PHPRtfLite_ParFormat();
// spaces between lines
$parFormat->setSpaceBetweenLines(1);
Background color
~~~~~~~~~~~~~~~~~~~~~~~~
Paragraph background color:
.. code-block:: php
<?php
// some bootstraping here
$parFormat = new PHPRtfLite_ParFormat();
$parFormat->setBackgroundColor('#FF0000');
.. _borders:
Borders
~~~~~~~~~~~~~~~~
.. code-block:: php
<?php
// some bootstraping here
$border = new PHPRtfLite_Border(
$rtf, // PHPRtfLite instance
new PHPRtfLite_Border_Format(2, '#00FF00'), // left border: 2pt, green color
new PHPRtfLite_Border_Format(1, '#FFFF00'), // top border: 1pt, yellow color
new PHPRtfLite_Border_Format(2, '#FF0000'), // right border: 2pt, red color
new PHPRtfLite_Border_Format(1, '#0000FF') // bottom border: 1pt, blue color
);
$parFormat = new PHPRtfLite_ParFormat();
$parFormat->setBorder($border);
There are some alternative ways to create borders:
.. code-block:: php
<?php
// some bootstraping here
// creating border in a different way: 1pt dotted red border with 0.5cm space
$border = PHPRtfLite_Border::create($rtf, 1, '#FF3333', PHPRtfLite_Border_Format::TYPE_DOT, 0.5);
.. code-block:: php
<?php
// some bootstraping here
// creating border in a different way: 1pt dotted red border
$border = new PHPRtfLite_Border($rtf);
// 2pt border in green color
$border->setBorders(new PHPRtfLite_Border_Format(2, '#00FF00'));
Border style types
^^^^^^^^^^^^^^^^^^
Border style types represented as class constants of ``PHPRtfLite_Border_Format`` are:
- ``TYPE_SINGLE``
- ``TYPE_DOT``
- ``TYPE_DASH``
- ``TYPE_DOTDASH``