DjVu

for Java,
Created By
Foxtrot
Technologies
Inc.


Home
License
Downloads
Examples


Release Notes
Deployment
Properties
API
Introduction


DjVuLibre
DjVuZone
Any2DjVu
LizardTech
PlanetDjVu


Sponsors
LizardTech Inc.
Internet Archive

 
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.

<html>
<head>
<title>Example</title>
</head>
<body bgcolor="#ffffff" leftMargin="0" topMargin="0">
<applet
	codebase="/java"
	code="DjVuApplet.class"
	archive="javadjvu.jar"
	width="640"
	height="480"
	style="border:0px none;margin:0px 0px 0px 0px;width:640;height:480">
<param name="data" value="/manuals/genfrac/GF3.0_UserGuide.djvu">
<param name="image" value="http://javadjvu.sourceforge.net">
<param name="cache_archive" value="javadjvu.jar">
</applet>
<a href="About.html">next test
</a>
</body>
</html>

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.html file 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:

<html>
<head>
<title>GF 3.0 UserGuide</title>
</head>
<body scroll="no" bgcolor="#ffffff" leftMargin="0" topMargin="0">
<script language="JavaScript">
<!--
var url="/manuals/genfrac/GF3.0_UserGuide.djvu";
var width=720, height=480;
if(window && window.innerWidth)
{
   width=window.innerWidth; height=window.innerHeight;
}
else if(document.body && document.body.clientWidth)
{
   width=document.body.clientWidth; height=document.body.clientHeight;
}
document.writeln('<applet ');
document.write('	style="border:0px none;margin:0px 0px 0px 0px;');
document.writeln('width:100%;height:100%"');
document.writeln('	code="DjVuApplet.class"');
document.writeln('	codebase="/java"');
document.writeln('	archive="javadjvu.jar"');
document.writeln('	width="'+(width-8)+'"');
document.writeln('	height="'+(height-8)+'" >');
document.writeln('<param name="data" value="'+url+'" >');
document.writeln('<param name="image" value="http://javadjvu.sourceforge.net">');
document.writeln('<param name="cache_archive" value="javadjvu.jar">');
document.writeln('A Java Enabled browser is required to view this page.');
document.write('</applet>');
// -->
</script><noscript>
<applet
        codebase="/java"
        code="DjVuApplet.class"
        archive="javadjvu.jar"
        width="720"
        height="480"
        style="border:0px none;margin:0px 0px 0px 0px;width:100%;height:100%">
<param name="data" value="/manuals/genfrac/GF3.0_UserGuide.djvu">
<param name="image" value="http://javadjvu.sourceforge.net">
<param name="cache_archive" value="javadjvu.jar">
</applet></noscript>
</body>
</html>

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.