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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 1999-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.1//EN"
"http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/core/context/resources/schema/dtd/document-v12.dtd">
<document>
<header>
<title>FOP Development: RTFLib (jfor)</title>
<version>$Revision$</version>
</header>
<body>
<section id="general">
<title>General Information</title>
<section id="intro">
<title>Introduction</title>
<p>The RTFLib package is an open-source, <em>independent</em> package suitable for writing RTF files in a java environment.
By <em>independent</em> we mean:</p>
<ul>
<li>Although it is used by FOP to generate FOP's RTF output, it is not dependent on FOP for any of its functionality.</li>
<li>It does not require FOP as a front-end, nor does it even require XSL-FO for input.
It essentially exposes an API of relatively high-level RTF construction routines to a host program.
This means it can be used anywhere RTF output is required and java is available.</li>
</ul>
<p>The FOP development team intends to keep the RTFLib package independent so that it can be used for other purposes.</p>
</section>
<section id="history">
<title>History</title>
<p>RTFLib was originally developed by <link href="mailto:bdelacretaz@apache.org">Bertrand Delacrétaz</link> and the <link href="http://www.jfor.org">jfor</link> team. jfor was written under an Apache-style license, and the jfor team contributed the code to the Apache Software Foundation in June, 2003. RTFLib is a subset of the original jfor project, which also includes an XSL-FO parsing mechanism for a complete XSL-FO to RTF solution.</p>
</section>
<section id="status">
<title>Status</title>
<p>Although FOP's implementation of the RTFLib package is very incomplete, the RTFLib package itself is relatively mature. RTFLib is only available in the trunk <link href="index.html#lines">line of FOP development</link>.</p>
<warning>This documentation is a work in progress. If you see errors or omissions, please report them to the <link href="index.html#mail-fop-dev">fop-dev mailing list</link>.</warning>
</section>
</section>
<section id="userdoc">
<title>User Documentation</title>
<section id="userdoc-overview">
<title>Overview</title>
<p>Perhaps the easiest way to see how to use RTFLib is by looking at an example. A set of test documents is part of the package, and can be <link href="http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/rtf/rtflib/testdocs/">viewed online</link>.
A quick look at the Abstract <link href="http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java?rev=HEAD&content-type=text/vnd.viewcvs-markup">TestDocument</link> class, and one of the Concrete subclasses, <link href="http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleDocument.java?rev=HEAD&content-type=text/vnd.viewcvs-markup">SimpleDocument</link> will provide the basics of how to use the package.</p>
<p>There are two basic concepts you will need to understand in order to use RTFLib:</p>
<ul>
<li>Documents are created by filling bigger containers with successively smaller containers, and eventually with content.</li>
<li>Attributes may be set for each container or content as it is created</li>
</ul>
<p>RTFLib handles the process of converting to and writing the RTF content as the document is created. All you need to do is flush the document at the end to make sure that the last pieces get written.</p>
</section>
<section id="userdoc-structure">
<title>Document Structure</title>
<warning>This section is very incomplete.</warning>
<p>The documentation in this section is intended to provide a high-level view of the process of building an RTF document. For more detailed API documentation of the various methods, be sure to consult the Javadocs for RTFLib.</p>
<p>The following table summarizes the various containers that can be created:</p>
<table>
<tr>
<th>Name</th>
<th>Class.Method where created</th>
<th>Attribute Set(s)</th>
<th>Valid children</th>
</tr>
<tr>
<td>Document Area</td>
<td>RtfFile.startDocumentArea()</td>
<td>Information Group, Document Formatting</td>
<td>Section</td>
</tr>
<tr>
<td>Section</td>
<td>RtfDocumentArea.newSection()</td>
<td>Section Formatting</td>
<td>Paragraph, ParagraphKeepTogether, Image, List, Before (Page Heading), After (Page Footer), JforCmd</td>
</tr>
<tr>
<td>Paragraph</td>
<td>RtfSection.newParagraph()</td>
<td>Paragraph Formatting, Character Formatting</td>
<td>Text</td>
</tr>
<tr>
<td>ParagraphKeepTogether</td>
<td>RtfSection.newParagraphKeepTogether</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Image</td>
<td>RtfSection.newImage</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Table</td>
<td>RtfSection.newTable</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>List</td>
<td>RtfSection.newList</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Before (Page Heading)</td>
<td>RtfSection.newBefore</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>After (Page Footer)</td>
<td>RtfSection.newAfter</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>JforCmd</td>
<td>RtfSection.newJforCmd</td>
<td>.</td>
<td>.</td>
</tr>
<tr>
<td>Text</td>
<td>RtfParagraph.newText()</td>
<td>Character Formatting</td>
<td>N/A</td>
</tr>
</table>
</section>
<section id="userdoc-attributes">
<title>Attributes</title>
<warning>This section is very incomplete.</warning>
<p>Attributes can be set for each container and piece of content in the document. The general approach is to build an RtfAttributes object containing the various attributes, then pass that RtfAttributes object to the method that creates the new container or content. See the Javadoc API documentation for RtfAttributes for details on the syntax for creating an RtfAttributes object. The following information lists the various attributes that can be set for each type of container.</p>
<section id="userdoc-attr-ig">
<title>Information Group</title>
<p>These attributes are set when creating a Document.</p>
</section>
<section id="userdoc-attr-df">
<title>Document Formatting</title>
<p>These attributes are set when creating a Document.</p>
</section>
<section id="userdoc-attr-sf">
<title>Section Formatting</title>
<p>These attributes are set when creating a Section.</p>
</section>
<section id="userdoc-attr-pf">
<title>Paragraph Formatting</title>
<p>These attributes are set when creating a Paragraph.</p>
<table>
<tr>
<th>Description</th>
<th>Attribute Name</th>
<th>Attribute Value</th>
<th>RTF Control Word</th>
</tr>
<tr>
<td colspan="4">.</td>
</tr>
<tr>
<th>Alignment</th>
<th colspan="3">.</th>
</tr>
<tr>
<td>Align Left</td>
<td>RtfText.ALIGN_LEFT</td>
<td>N/A (boolean)</td>
<td>\ql</td>
</tr>
<tr>
<td>Align Right</td>
<td>RtfText.ALIGN_RIGHT</td>
<td>N/A (boolean)</td>
<td>\qr</td>
</tr>
<tr>
<td>Align Centered</td>
<td>RtfText.ALIGN_CENTER</td>
<td>N/A (boolean)</td>
<td>\qc</td>
</tr>
<tr>
<td>Align Justified</td>
<td>RtfText.ALIGN_JUSTIFIED</td>
<td>N/A (boolean)</td>
<td>\qj</td>
</tr>
<tr>
<td>Align Distributed</td>
<td>RtfText.ALIGN_DISTRIBUTED</td>
<td>N/A (boolean)</td>
<td>\qd</td>
</tr>
<tr>
<td>Kashida justification</td>
<td>not implemented</td>
<td>0-20 (integer)</td>
<td>\qkN</td>
</tr>
<tr>
<td>Thai Distributed justification</td>
<td>not implemented</td>
<td>N/A (boolean)</td>
<td>\qt</td>
</tr>
<tr>
<th>Indentation</th>
<th colspan="3">.</th>
</tr>
<tr>
<td>Left indent body</td>
<td>RtfText.LEFT_INDENT_BODY</td>
<td>(int) "hundredths of a character unit" (?)</td>
<td>\li</td>
</tr>
<tr>
<td>Left indent first</td>
<td>RtfText.LEFT_INDENT_FIRST</td>
<td>(int) "hundredths of a character unit" (?)</td>
<td>\fi</td>
</tr>
<tr>
<th>Borders</th>
<th colspan="3">.</th>
</tr>
<tr>
<td>Bottom single border</td>
<td>RtfText.BDR_BOTTOM_SINGLE</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrs</td>
</tr>
<tr>
<td>Bottom double border</td>
<td>RtfText.BDR_BOTTOM_DOUBLE</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrdb</td>
</tr>
<tr>
<td>Bottom embossed border</td>
<td>RtfText.BDR_BOTTOM_EMBOSS</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdremboss</td>
</tr>
<tr>
<td>bottom dotted border</td>
<td>RtfText.BDR_BOTTOM_DOTTED</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrdot</td>
</tr>
<tr>
<td>bottom dashed border</td>
<td>RtfText.BDR_BOTTOM_DASH</td>
<td>Boolean?</td>
<td>brdrb\\brsp40\\brdrdash</td>
</tr>
</table>
</section>
<section id="userdoc-attr-cf">
<title>Character Formatting</title>
<p>These attributes are set when creating a Paragraph, or Text.</p>
<table>
<tr>
<th>Description</th>
<th>Attribute Name</th>
<th>Attribute Value</th>
<th>RTF Control Word</th>
</tr>
<tr>
<td>Bold</td>
<td>RtfText.ATTR_BOLD</td>
<td>N/A (boolean)</td>
<td>\b</td>
</tr>
<tr>
<td>Italic</td>
<td>RtfText.ATTR_ITALIC</td>
<td>N/A (boolean)</td>
<td>\i</td>
</tr>
<tr>
<td>Underline</td>
<td>RtfText.ATTR_UNDERLINE</td>
<td>N/A (boolean), or (int) 0 to turn underlining off</td>
<td>\ul</td>
</tr>
<tr>
<td>Font Size</td>
<td>RtfText.ATTR_FONT_SIZE</td>
<td>(int) font size in half-points</td>
<td>\fs</td>
</tr>
<tr>
<td>Font Family</td>
<td>RtfText.ATTR_FONT_FAMILY</td>
<td>(int) entry in document font-table</td>
<td>\f</td>
</tr>
<tr>
<td>Font Color</td>
<td>RtfText.ATTR_FONT_COLOR</td>
<td>(int) entry in document color-table</td>
<td>\cf</td>
</tr>
<tr>
<td>Background Color</td>
<td>RtfText.ATTR_BACKGROUND_COLOR</td>
<td>(int) entry in document color-table</td>
<td>\chcbpat</td>
</tr>
</table>
</section>
</section>
</section>
</body>
</document>
|