This Project is Sponsored By
LizardTech Inc. and
Internet Archive


Home
License
Downloads
Examples


Release Notes
Deployment
Properties
API
Introduction


DjVuLibre
DjVuZone
Any2DjVu
LizardTech
PlanetDjVu
SourceForge.net

Project Page |  Home |  Forums |  Tracker |  Bugs |  News |  Files |  Cvs


How to Deploy the Java DjVu Viewer Applet

The Java DjVu Applet is designed to be embedded inside larger HTML pages. It does not require the web server to support the DjVu MIME type, but only that the DjVu files will be served as binary files.

Basics

The standard way to include an applet inside an HTML page is to use the <applet> tag.

There are several <applet> attributes needed to deploy the applet.

In the above example we used a codebase="/java" , code="DjVuApplet.class" , and archive="javadjvu.jar" . This means the initial class will be loaded from the URI "/java/DjVuApplet.class", and the rest of the code will be loaded from the URI "/java/javadjvu.jar".

The appearance of the Java DjVu Applet may be further customized by specifying additional properties. Refer to the Properties.htmlfile for a complete list of properties supported by the Java DjVu Applet.

Using <embed> and <object> tags.

Java applets may also be deployed using <embed> and/or <object> tags for browsers using J2SE Runtime Edition 1.3.1 or later. The primary reason why a web developer would wish to use these tags instead of <applet> would be to enable automatic deployment of the J2SE Runtime Edition. Fortunately, there is no need for web developers to deal with the complicated syntax of <object> and <embed>. Part of the J2SE development kit is a tool called "HTMLConvert". This tool can automatically convert web pages using <applet> tags to <object> and <embed> tags. Web developers can write and test web pages using the simple <applet> tag syntax and then convert the pages using the HTMLConvert tool.

There are a few enhancements of <object> and <embed> tags over the applet tag worth mentioning:

  1. The width and height of <object> and <embed> tags may be relative rather than absolute. This means it is possible to specify a value like width="100%" or height="100%" when using <object> or <embed> rather than selecting a fixed size like width="640" and height="480"
  2. The class specified by the code base attribute may be inside the jar file. This means the com.lizardtech.djview.Applet.class class may be loaded directly from the jar file, rather than first loading DjVuApplet.class.

Relative sizes with <applet> tags

Unfortunately, the <applet> tag can only be specified with fixed height and width attributes. The most common solution to this problem is to use a style attribute, but this still fails for Mozilla based browsers on MacOS X. Another possible way to avoid this limitation is to use the HTMLConvert tool described above. A third alternative is to use JavaScript as in the following example:

With this code we generate an <applet> tag that uses nearly 100% of the page. An 8 pixel border is provided to prevent the browser from adding scrollbars. For browsers which do not support querying the page size and style sheets, a default of 720 by 480 pixels will be used.