
 Exporting and printing jfig files:

 Perhaps the most common usage of xfig/jfig is to produce drawings
 for LaTeX (or Word etc.) documents. This requires to convert the 
 FIG format into a file format understood by the word processor.

 Contents:

 1) built-in printing and Postscript export
 2) built-in PDF export via iText library
 3) built-in image export via ImageIO
 4) fig2dev
 5) fig2dev on the server
 6) fig2dev problems


------------------------------------------------------------------------


 1) Built-in printing and Postscript export

 The easiest way to export your FIG file into another format is to use
 the Java printing functions. Select "Menu->File->Print (java native)"
 and select the options offered by the print dialog. To convert your
 drawings to Postscript format, just select a Postscript printer and
 select "print to file":

 o On Unix systems, printing will always generate Postscript output, 
   and you should be able to select paper format and orientation. 

 o On Windows, you have full access to the Windows printing system.

   Note that you can always install a Postscript printer driver and
   redirect the output to a file, even if no Postscript printer is 
   actually attached to your system.

   However, some Windows printer drivers generate bad Postscript code.
   If in doubt, use the generic Postscript driver from Adobe. 
   Another choice is to use one of the Apple Color Laserwriter series 
   drivers, which seem to generate good, portable, Postscript output.

 Note that the current version (jfig3) requires and uses the printing
 function from JDK/JRE 1.4. You should be able to select paper format,
 paper orientation, and page borders. If it fits to the selected paper
 size, your figure will be printed in original size. Otherwise, the
 figure is automatically scaled down to fit. Actual printing will use 
 the Java2D-based rendering for good output quality. 

 Unfortunately, it is still impossible to tell the Java-based print
 function to use custom paper sizes. You might have to rely on an
 external application (like the ps2eps or ps2epsi converters) to
 create valid Encapsulated Postscript files from the print output.

 When the print functions from JDK/JRE 1.4 are not detected, jfig
 will fall back on the Java 1.1 printing functions, which are no 
 longer supported. In this mode, the current coordinate transformation
 is used for printing, and you may have to experiment a little in
 order to find accepatable zoom and translation settings.
 The print quality depends on your Java virtual machine and the printer
 driver. In general, Java 1.1 gives poor quality results: font rendering
 is ok, but lines are limited to the resolution of 72dpi. This might 
 result in "jaggy" lines for arcs and splines.

 

 ------------------------------------------------------------------------


 2) PDF export via iText library

 As PDF is becoming the de-facto standard document format, many users
 have asked for a way to export FIG drawings to PDF format. One way
 to achieve this is to use external programs like the fig2dev converter,
 which is explained in detail below (see section 4).

 Starting with version jfig 2.20, jfig also includes an interface to
 the "iText" PDF library, allowing to export the current figure 
 directly to a PDF file without requiring external programs. Unlike
 fig2dev, which relies on and is limited to the FIG format standard,
 the iText library can also export some of the non-standard features
 of jfig to PDF documents. For example, it is possible to export
 drawings using non-standard fonts or TeX-mode attributed strings,
 including all math symbols from the Computer Modern fonts.

 If you use pdflatex, the PDF export options from jfig might be all
 you need to include high-quality vector graphics in your documents.

 Currently, the PDF export always uses the bounding box of your drawing 
 as the page format of the resulting PDF, so that you can integrate
 the PDF figures into your pdflatex (or OpenOffice) documents. 
 If the bounding box calculation turns out to be slightly wrong
 (e.g. for spline objects), you might want to include an additional
 rectangle object, surrounding all other objects, into your object.
 The same trick is useful to ensure that you documents end up in one
 of the standard page sizes like DIN A4 or US Letter.

 If you plan to use the iText-based export, please make sure to
 download the jfig3-itext.jar archive, which already includes the
 iText library classes.

 Naturally, the integration of the 'bare' jfig3.jar archive and
 an existing copy of iText is possible. Please download and read
 the jfig-tutorial for further information.

 NOTE: while the iText-based PDF export is now enabled in the free 
 evaluation version of jfig, it will add extra objects to your files.
 Just register jfig to enable fully the PDF export.

  

 ------------------------------------------------------------------------


 3) bitmap image export: JPEG, PNG, PPM

 Another export option is to use the "Menu->Export->JPG/PNG/PPM..." 
 commands. This will open the image-export-options dialog window
 and prompt you for the output filename and some options.

 When started, the export functions create an internal image buffer
 of the required size and render your figure into that buffer,
 which is then written to an output file of the selected type.
 This may take a few seconds but should work with any Java virtual
 machine, the output quality depending on the selected settings like
 anti-aliasing. 

 Usually, the PNG format is the best choice, but JPEG can be useful
 if your figures include large embedded JPEG images. The PPM format
 is uncompressed, but can be useful to postprocess the image files
 with your own tools. Naturall, you can use your favorite image
 viewer (PaintShopPro, Microsoft Photo Editor, GIMP, xv, ...) to
 edit and convert the jfig-generated images.

 Note that the option to create GIF-format files has been dropped
 in jfig3, due to both licensing issues and technical problems.
 When anti-aliasing is on, the resulting image files almost always
 include more than the maxinum number of 256 colors supported by GIF.



 ------------------------------------------------------------------------


 4) fig2dev

 Like xfig, jfig writes and reads FIG files, but offers no import
 or export filters to other file formats. However, it is possible
 to use the xfig companion program "fig2dev" to convert FIG files
 into many other output formats, including Postscript, HPGL, or
 LaTeX drawing commands.

 Unfortunately, there is no Java implementation of fig2dev available.
 Instead, you have to compile the fig2dev program for yourself, or
 download a precompiled binary from our server. Most Linux and Unix
 systems have fig2dev preinstalled together with the X11 programs.

 For Windows, you can download the fig2dev-windows.zip archive
 from our webpage, which includes a fig2dev.3.2.3 executable for
 Windows 95/98/NT/2000. See the README in the fig2dev-windows.zip
 archive for details and copyright information. 
 After installing the fig2dev.exe and cygwin.dll, you should try to 
 run the program "by hand" directly from the command line. Open a DOS 
 shell and try 
 fig2dev -help
 fig2dev -L ps somefile.fig > somefile.ps
 This should generate the Postscript version of your input file.
 At the moment, the Windows fig2dev only supports JPEG format for 
 embedded images.

 Note: It is probably a good idea to write a small script (or makefile)
 to run fig2dev with the required options and for all files in question,
 instead of calling fig2dev directly.  

 To access the external fig2dev program, jfig generates a String with
 the command line and calls the system (e.g. DOS/Windows) to execute 
 the command.  You can specify parts of the command via settings in your 
 .jfigrc file(s). Again, the whole process is currently limited by
 a number of Java VM bugs.

 The approach taken by jfig is:

 o) save the current figure to a temporary file.
 o) call fig2dev 
 o) don't wait for fig2dev to finish, because this deadlocks easily on
    many systems
 o) because we don't know that fig2dev is finished, we cannot remove the
    tmp files. This will be done when you exit jfig.

 Please read the jfig tutorial for further information about LaTeX
 export and the Postscript/LaTeX-overlay export options via fig2dev.

 ---

 Volunteers: The whole process is error prone and depends on your 
 installation (what JVM, what fig2dev, ...). The export code in jfig 
 was written two years ago and has never been improved or fixed, because
 the script/makefile approach is better. However, many people like to
 export each figure by selecting all the export options individually.
 Please consider to contribute a fixed Java version of the corresponding
 class(es), namely jfig.gui.JExportOptionsDialog. The source code
 for these classes is included with the latest jfig class archive.


 ------------------------------------------------------------------------


 5) fig2dev on the server

 Given the current state of affairs with running fig2dev on Windows,
 you might be tempted to run fig2dev on a Linux or Unix box near you.
 This is in fact what the author of these lines does:
 I use jfig on my Linux and Windows systems - the latter with a 
 three-button mouse driver - but I don't run fig2dev on Windows at all. 
 We have a Samba server running, and all the FIG files are on the server.
 To export, I simply log onto the server and start my export script.

 The jfig.jar archive contains a simple example script to convert all 
 .fig files in the current directory to Postscript at 90% magnification 
 in file /jfig/doc/run-fig2dev:

 #!/bin/csh -f
 foreach i (*.fig)
 echo $i
 ./fig2dev -L ps -P -m 0.9 $i `basename $i .fig`.ps
 end


------------------------------------------------------------------------


 6) fig2dev problems

 The algorithm used by fig2dev for splines is different from the
 algorithm used in xfig 3.2, which is different from the algorithm
 used in xfig 3.1. Jfig uses either the 3.2 or the 3.1 algorithm...

 Therefore, "interpolated" splines may look quite different on paper 
 after exporting and printing than they looked in xfig on the screen. 
 This is most notable for splines which have "sharp" curves. If this 
 is a problem, use "standard" (instead of "interpolated") splines...

