<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<article>
  <title>HOWTO</title>
  <subtitle>Configure an External FO Processor</subtitle>
  <articleinfo>
    <author>
      <firstname>Sean</firstname>
      <surname>Wheller</surname>
      <email>seanwhe@yahoo.com</email>
    </author>
  </articleinfo>
  <abstract>
    <para>This article explains how to install an External FO Processor in &lt;oXygen/> XML Editor 2 or higher.</para>  </abstract>
  <sect1>
    <title>Introduction</title>
    <para>The Apache Formatting Objects Processor (FOP), bundled with the &lt;oXygen/> XML Editor, is an
      XSL Rendering engine or print formatter application written in Java. FOP enables XSL-FO
      formatted files to be transformed to the following formats: PDF, PCL, PS, SVG, XML (area tree
      representation), Print, AWT, MIF and TXT.</para>
    <para>FOP does not currently implement all the objects and properties detailed in the <ulink
        url="http://www.w3.org/TR/2001/REC-xsl-20011015/">XSL-FO Version 1.0 W3C
      Recommendation</ulink>. The reason for this is that print formatting is a very complex and
      large subject, as is reflected by the size and complexity of the XSL-FO Recommendation itself.
      So complex, that the W3C itself defines and recognizes three levels of conformance
      against which FO Processors can be measured for compliance with the Recommendation.</para>
    <para>As a result each of the FO Processors, available to the market, implement the
      Recommendation to a greater or lesser degree. Commercially available FO Processors like
        <ulink url="http://xep.xattic.com">XEP</ulink> generally implement a greater portion of the recomendation.</para>
    <para>To accommodate the use of FO Processors other than the Built-in Apache FOP, or to enable use of a more current
      FOP version, the &lt;oXygen/> XML Editor has been built with the ability to define what are called
      &quot;External FO Processors&quot;. External because they are installed separately to
      the &lt;oXygen/> XML Editor and will generally create a separate thread when executed by Oxygen.</para>
    <para>In this document I will explain how to install and configure an External FO Processor. </para>
  </sect1>
  <sect1>
    <title>Instruction</title>
    <para>The processor we will be installing is the Apache FOP. If you are installing a different
      FO Processor, please exchange names, syntax and parameters to match your application.</para>
    <para>Also, my operating system of choice is Windows. So if you have one of the Linux operating
      systems please lookout for the notes. They will point out any differences that may apply to you.</para>
    <para>Before you proceed, please ensure that you have copied and installed the new FO processor
      as per the instructions of the vendor. It's also a good idea to test that it works from the
      command line or by using a utility that may have been provided by the vendor.</para>
    <procedure>
      <title>Configuring an External FO Processor</title>
      <step>
        <para>Start Oxygen.</para>
      </step>
      <step>
        <para>From the main menu select <menuchoice>
            <guimenu>Options</guimenu>
            <guimenuitem>Preferences</guimenuitem>
          </menuchoice>. The Preferences dialog is displayed.</para>
      </step>
      <step>
        <para>From the list of preference categories select the <option>FO processors</option>
          option. The FO processors options are displayed.</para>
        <mediaobject>
          <imageobject>
            <imagedata fileref="fo-options.gif" format="GIF" scale="65"/>
          </imageobject>
        </mediaobject>
      </step>
      <step>
        <para>
          <action>Click</action> the <guibutton>New</guibutton> button. The Command line dialog is
            displayed.</para>
        <mediaobject>
          <imageobject>
              <imagedata fileref="command-line.gif" format="GIF"/>
          </imageobject>
        </mediaobject>
      </step>
      <step>
        <para>Complete the fields as per <xref linkend="tbl_commandline"/>, then <action>click</action>
          <guibutton>OK</guibutton>. The new FO Processor is listed in the <guilabel>External FO
          processors</guilabel> list.</para>
        <mediaobject>
          <imageobject>
            <imagedata fileref="fo-options-new-proc-defined.gif" format="GIF" scale="65"/>
          </imageobject>
        </mediaobject>
      </step>
      <step><para><action>Click</action> the <guibutton>OK</guibutton> button to save your changes and return to the editor.</para></step>
      <step>
        <para>In the "Edit scenario" dialog click on "FO Proessor" tab. Check the "Perform FO Processing" checkbox option. Select the created external processor from the "Processor" combo box.</para>
        <mediaobject>
          <imageobject>
            <imagedata fileref="fo-edit-scenario.gif" format="GIF"/>
          </imageobject>
        </mediaobject>
      </step>
      <step>
        <para>Test the new FO Processor by running the transformation. The processing messages and results will be shown in the Message Pane of the editor.</para>
        <mediaobject>
          <imageobject>
            <imagedata fileref="fop-messages.gif" format="GIF" scale="68"/>
          </imageobject>
        </mediaobject>
      </step>
    </procedure>
    <note>
      <para>If you want to process documents with references to PNG format graphics please see <xref linkend="installing_jimi"/>.</para>
    </note>
    <table id="tbl_commandline">
      <title>The Command line dialog fields</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Field</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>
              <para>Name</para>
            </entry>
            <entry>
              <para>The name that will be displayed in the list of available FOP processors on the
                FOP tab of the Transforming Configuration dialog.</para>
            </entry>
          </row>
          <row>
            <entry>
              <para>Description</para>
            </entry>
            <entry>
              <para>The description of the FO processor displayed in the <guilabel>External FO
                processors</guilabel> list.</para>
            </entry>
          </row>
          <row>
            <entry>
              <para>Working directory</para>
            </entry>
            <entry>
              <para>The directory in which the intermediate and final results of the processing will
                be stored. If an output file destination is specified this will override the working
                directory. To specify the current directory enter a period &quot;. &quot;.
                Alternatively use the <guibutton>Browse</guibutton> button to define the path.</para>
            </entry>
          </row>
          <row>
            <entry>
              <para>Command line</para>
            </entry>
            <entry>
              <para>Specify the command line that will start the FO processor. This command is
                typically specific to each processor, please refer to your processor documentation
                for instructions on how to run as a &quot;Standalone Application&quot;.</para>
              <para>With Apache FOP a shell script called <filename>fop.sh</filename> is provided. Execute
                this script by first calling a shell like <application>BASH</application>, then pass
                it the options you require (see <xref linkend="example_cmd"/>).</para>
            </entry>
          </row>
        </tbody>
      </tgroup>
    </table>
    <example id="example_cmd">
      <title>FOP Command (Linux)</title>
      <para>
        <command>bash ../pathto/fop-0.93/fop.sh -fo ${fo} -${method} ${out}</command>
      </para>
    </example>
    <note>
      <para>For Windows the corresponding file to <filename>fop.sh</filename> is
        <filename>fop.bat</filename>. This file can be called directly, there is no need to call
        <application>command</application>. A <application>Command Prompt</application> session will
        be automatically created when &lt;oXygen/> executes <filename>fop.bat</filename>. Here is an example:</para>
      <para>
        <command>c:\pathto\fop-0.93\fop.bat -fo ${fo} -${method} ${out}</command>
      </para>
    </note>
  </sect1>
  <sect1 id="installing_jimi">
    <title>Installing JIMI</title>
    <para>Jimi is a class library for managing images. If your FO Processor does not bundle the JIMI
      class library and you wish to process documents that reference to graphics in PNG format,
      download a copy from the <ulink url="http://java.sun.com/products/jimi/#">Sun Java Web Site</ulink>.</para>
    <procedure>
      <title>Install Jimi</title>
      <step>
        <para>Extract the downloaded archive and locate a file called <filename class="directory">JimiProClasses.zip</filename>.</para>
      </step>
      <step>
        <para>Copy this file to your FO Processors library directory. For Apache FOP this directory
          is <filename class="directory">fop-0.93/lib/</filename>.</para>
      </step>
      <step>
        <para>Rename <filename class="devicefile">JimiProClasses.zip</filename> to <filename class="devicefile">JimiProClasses.jar</filename>
        </para>
      </step>
    </procedure>
    <note>
      <para>On Windows rename <filename class="devicefile">JimiProClasses.zip</filename> to <filename class="devicefile">Jimi-1.0.jar</filename>
      </para>
    </note>
  </sect1>
</article>
