01.JAVA/Java2008. 11. 19. 13:48
반응형

Orinoco - A Java API to generate PDF documents

This is the home page of Orinoco: a Java API allowing Java developers to generate PDF documents.

Yet another PDF generator?

There are many Java PDF generators available - why bother with another one? The motivation arose when trying to use a commercially available PDF generator to deliver adhoc reports through a browser. The PDF generator offered everything: charts, drawings, images etc., but all that was required was merely to lay out some text in a tabular format with a few headings in bold. The tool we were using could certainly do this, but when generating larger reports (around 70 pages) it was taking so long to generate the PDF that the HTTP request timed out and the users ended up with nothing.

Rather than spend the time finding another generator and negotiating licensing agreements I decided to write a PDF generator which satisfied our meagre functional requirements and focussed on delivering the generated document quickly.

Orinoco offers the functionality needed to generate text reports (no graphics) and it is very quick: it can generate a document of a couple of hundred pages in a few seconds.

Features

  • Allows presentation of text in a variety of fonts and styles
  • Headers, footers and page numbering
  • Layout data in tables, with headings
  • Background shading
  • Tabs
  • Paper sizes and page orientation
  • Automatically handles line wrapping and page breaks

    Click here to see a sample

    This example shows the extended character set supported with orinoco, together their octal character codes

    Limitations

    Only the "standard" set of postscript fonts are supported (Times Roman, Helvetica,Courier etc). There is no support for drawing (other than straight lines) or embedding images.

    Using the library

    Orinoco requires a set of font information files, which are packaged along with the distribution in a subdirectory called fonts. Whenever the API is invoked it will look for this subdirectory under the system property called "resources".

    The easiest way to set this system property is to use the -D option when invoking the JVM eg.

    java -Dresources=/path/to/resources ...

    Orinoco will therefore expect to find the fonts directory on the system as /path/to/resources/fonts

    Demo

    To invoke the demo program which generates this PDF document, open a command line prompt in the "orinoco" directory, which was created when the distribution was untarred:

    java -classpath orinoco.jar -Dresources=resources orinoco.demo.Test -pdf test.pdf

    Note the use of -D option to set the resources system property. This points to the immediate subdirectory "resources" and orinoco will look in here for the subdirectory called "fonts".

    Examine the source code src/orinoco.demo/Test.java to see how the orinoco API can be used to generate PDF documents.

    Installation

    Orinoco comes packaged as a zipped tar file, called something like orinoco_1_0_3.tar.gz. To unpack on UNIX systems, at the command line type

    gunzip orinoco_1_0_3.tar.gz      followed by
    tar xf orinoco_1_0_3.tar

    On Linux systems this can be accomplished within the single command

    tar zxf orinoco_1_0_3.tar.gz

    On Windows/NT systems, the archive may be unpacked visually using a utility such as Winzip.

    Whatever the unpacking process, the application will be placed in a subdirectory called orinoco. The top level directory contains this html page and the pre-built jar file, orinoco.jar. The resources directory contains the fonts subdirectory, which in turn contains the important font information files. The docs directory contains the javadoc documentation for the public classes, the build directory contains the buildfile (requires ant ) and the src directory contains the source code for the java classes.

    Licensing

    Orinoco is issued on under the GNU Lesser General Public License. For further information click here.

    Download Orinoco

    Change History

    Return to my home directory

    This site last updated 18th December, 2007

  • Posted by 1010