See also the jfor homepage.
Last revised September 3rd 2002 by Bertrand Delacrétaz.
(CreateTestDocuments class name was wrong)
jfor was initially written by Bertrand Delacretaz (bdelacretaz@codeconsult.ch), and
is released under its own Apache-style license, see
http://www.jfor.org/jfor-license.html.
Please note what the license says in more detail:
jfor comes without any warranty of any kind - use at your own risk (no guts, no glory...).
jfor converts XML documents conforming to the XSL:FO specification to RTF format, the goal being to use common XSL stylesheets to generate PDF (using FOP or similar) and RTF (using jfor) documents.
Although there are PDF-to-RTF converters, the RTF that they generate usually loses too much structure to be easily editable. jfor attempts to preserve the structure of the document (a table is a table, a list is a list, etc.), which can cause some loss of presentation information (distances between elements, etc.).
jfor releases are tested with:
Both a command-line converter and an adapter for Cocoon 1.8 are provided, and Cocoon 2 includes an RTFSerializer that uses jfor (see the jfor/Cocoon 2 HOWTO for more info).
jfor also includes a general-purpose RTF generation library, see package org.jfor.jfor.rtflib.testdocs for usage examples.
Despite serious limitations regarding the interpretation of XSL-FO constructs, jfor can be used productively to generate RTF documents, often with some adjustments to the XSL-FO documents to work around jfor's limitations.
In theory, jfor should not generate invalid RTF documents, but as the RTF spec is a moving target, word processor crashes upon opening documents created by jfor are fairly possible. Unfortunately, it is too late to uninvent RTF.
See the sample XSL-FO files provided in the samples directory of the source distribution for examples of what works and what doesn't work in the current version.
java -cp $JFOR_HOME/dist/lib/jfor.jar org.jfor.jfor.rtflib.testdocs.CreateTestDocuments outdirThe output of this command should be like:
CreateTestDocuments - using jfor V0.1 - see http://sourceforge.net/projects/jfor Generates documents to test the jfor RTF library. Generating document /tmp/rtfout/SimpleDocument.rtf... Generating document /tmp/rtfout/TextAttributes.rtf... Generating document /tmp/rtfout/SimpleTable.rtf... Generating document /tmp/rtfout/SimpleLists.rtf... Generating document /tmp/rtfout/ListInTable.rtf... CreateTestDocuments - all done.You should then be able to open the generated documents with your favorite word processor. The contents are meant to be self-describing.
java \ -cp $JFOR_HOME/lib/xerces.jar:$JFOR_HOME/dist/lib/jfor.jar \ ch.codeconsult.jfor.main.CmdLineConverter \ $JFOR_HOME/samples/cocoon/minimal.fo.xml simple.rtfThe output of which should be like:
jfor V0.7 - see http://sourceforge.net/projects/jfor Converting XSL:FO file '/home/bert/work/jfor/samples/cocoon/minimal.fo.xml' to RTF output 'simple.rtf'... jfor.INFO:jfor V0.7 - setting up conversion... jfor.INFO:Parsing xsl:fo document... jfor.DEBUG:Element 'fo:layout-master-set' (including child elements) ignored due to NullBuilder ignore list jfor.DEBUG:Element 'fo:page-sequence' ignored due to default NullBuilder jfor.DEBUG:Element 'fo:flow' ignored due to default NullBuilder jfor.INFO:Writing out RTF... jfor.INFO:Done converting xsl:fo to RTF. jfor.DEBUG:conversion took 269 milliseconds. Done writing RTF output 'simple.rtf'.
formatter.type.xslfo/rtf = ch.codeconsult.jfor.cocoon.cocoon18.Cocoon18FoToRtfFormatter formatter.xslfo/rtf.MIME-type = application/msword-restart tomcat
xslfo/rtf: RTF Formatter using jfor V0.1 [ MIME type: application/msword ]-copy file $JFOR_HOME/samples/cocoon/minimal.fo.xml to a directory served by cocoon. Requesting this file through a browser should deliver an RTF version of this file. If using Internet Explorer, you might need to add ?dummy=file.rtf at the end of the URL so that is uses the correct file handler.
Binaries are available for download on our SourceForge project page.
If you want to build jfor yourself, you need the following libraries and tools, which are NOT currently included in the jfor downloads:
The instructions below apply to a linux system. Contributions of instructions for other systems are welcome.
$ ant Buildfile: build.xml init: [mkdir] Created dir: /home/bert/work/jfor/build compile: [javac] Compiling 57 source files to /home/bert/work/jfor/build dist: [mkdir] Created dir: /home/bert/work/jfor/dist/lib [jar] Building jar: /home/bert/work/jfor/dist/lib/jfor.jar BUILD SUCCESSFUL Total time: 5 seconds $