Readme Contents
Introduction
Features
System Requirements
Using the Applet
JavaScript API
Copyright Notice
License Terms
Introduction
The
EmbedPDF applet can be used to embed a PDF document into a HTML page.
Features
- CMYK images.
- Sub-pixel Antialiasing
- Hyperlinks
- Page rotation in steps of 90 °
- Printing
- JavaScript API
- Open PDF document in browser.
The following features are not implemented:
- PDF documents with advanced features can not be displayed.
- Text can not be selected and copied from the document.
- There is no search function.
System Requirements
Needs a Java J2SE 6 capable internet browser.
Using the Applet
There are two versions of the applets. One which includes all the font files internally, and one which reads the fonts from separate font files.
If you choose the version with included font files, you need to upload the following files to your web-server:
- EmbedPDF.jar
- EmbedPDF.jar.pack.gz
If you choose the version with separate font files, you need to upload the following files to your web-server:
- EmbedPDF.jar
- EmbedPDF.jar.pack.gz
- d050000l.pfb
- n019003l.pfb
- n019004l.pfb
- n019023l.pfb
- n019024l.pfb
- n021003l.pfb
- n021004l.pfb
- n021023l.pfb
- n021024l.pfb
- n022003l.pfb
- n022004l.pfb
- n022023l.pfb
- n022024l.pfb
- s050000l.pfb
The file example.html shows how to
embed the applet into a HTML document. It contains the HTML statements as
provided below. Please note that the parameter values of the applet tag are case sensitive!
Required HTML tags are printed in bold letters.
<html>
<body>
<applet
id="embedPDF"
code="EmbedPDF.class"
codebase="."
archive="EmbedPDF.jar"
width="700"
height="620"
>
<param name="pdf" value="example.pdf"/>
<param name="fonts" value="."/>
<param name="enableOpenWindow" value="true"/>
<param name="enableSubpixelAA" value="false"/>
<!-- Parameters for Sun's Java plug-in: -->
<param name="codebase_lookup" value="false">
<param name="classloader_cache" value="false">
<param name="java_arguments" value="-Djnlp.packEnabled=true"/>
<param name="image" value="Splash.gif"/>
<param name="boxborder" value="false"/>
<param name="centerimage" value="true"/>
<param name="boxbgcolor" value="white">
<param name="boxfgcolor" value="black">
<param name="boxmessage" value="Loading EmbedPDF...">
<!-- Provide a link to the PDF-document for browsers without Java support: -->
<a href="example.pdf">example.pdf</a>
</applet>
</body>
</html>
Parameter |
Required |
Type |
Description |
|
id |
optional |
text |
The id attribute can be used to access the applet from JavaScript. See JavaScript API.
|
code |
required |
text |
The code attribute lets the browser know which Java class it must
use to show the applet. The value must be "EmbedPDF.class ".
|
codebase |
required |
url |
You can use the codebase attribue to restrict access of the applet to your web-server. The applet can only access files on the server that are in a sub-path of codebase.
Therefore codebase must be the common parent directory of the PDF documents that you want to display, and of the Java archive files (.jar, and .jar.pack.gz).
Usually "." is the best choice for codebase. This way, the applet can access all files in the path which contains the HTML page.
|
archive |
required |
url |
The archive attribute gives the URL of the Java archive which contains the code of the applet.
Please note that on most web-servers the case of this
value must match the case of the file name
"EmbedPDF.jar ".
If you specify the parameters for Sun's Java plug-in, you have to store the file "ANIMApplet.jar.pack.gz " in the same directory where you stored "ANIMApplet.jar ".
The archive URL is relative to the codebase URL.
|
width |
required |
number |
Width and height of the applet.
|
height |
required |
number |
|
pdf |
required |
url |
The file-name of the PDF document that you want to display.
The URL must point to a document which is in a sub-path of codebase.
|
|
fonts |
required |
url |
The folder which contains the font files (the location of the .pfb files).
There are two versions of EmbedPDF.jar. One with included font files and one with separate font files.
If you use EmbedPDF.jar with included font files, you must not specify this parameter.
If you use EmbedPDF.jar with separate font files, you must upload all the .pfb files to your server, and you must specify this parameter, so that EmbedPDF knows where to find its fonts.
The URL must point to a document which is in a sub-path of codebase.
|
enableOpenWindow |
optional |
boolean |
Set this to "false" to remove the "Open PDF in new Window" button from the applet.
|
enableSubpixelAA |
optional |
boolean |
Set this to "true" to enable subpixel antialiasing. This may improve the legibility of text on LCD screens.
Please note that the current implementation requires a lot of memory to achieve the antialiasing. Also note that the text may exhibit some color fringing.
|
boxbgcolor |
|
color |
The background color of the applet. This color should match the background color of your HTML page.
Specify a hex value (e. g. "0xff0000" or "#ff0000"), three RGB
values (e.g. "255,0,0") or an HTML color name (e.g. "red"). The default
value depends on the browser settings.
|
boxfgcolor |
|
color |
This parameter specifies the foreground color for messages
displayed on the applet. This color should be different from boxbgcolor.
Specify a hex value (e. g. "0xff0000" or "#ff0000"),
three RGB values (e.g. "255,0,0") or an HTML color name (e.g. "red").
The default value depends on the
browser settings.
|
boxMessage |
|
text |
If the browsers uses the Java Plug-In from Sun, this parameter specifies
a message that is shown while the applet is being loaded.
|
image |
|
url |
Specifies
the image to be shown while the applet is loading.
This is often referred to as a "splash screen". |
|
centerimage |
|
boolean |
Set this to "true" if you want to center the splash image.
Set this to "false" if you want to display the splash image at the top left corner of the applet. |
JavaScript API
The EmbedPDF applet can be accessed from JavaScript. To this, you can assign an id to the applet in the <applet> tag. If you add more than one applet to a page, assign an individual id to each.
<html>
<body>
<applet id="embedPDF" code="EmbedPDF.class" codebase="." archive="EmbedPDF.jar"
width="600" height="400"
>
<param name="pdf" value="example.pdf"/>
</applet>
</body>
</html>
The Javascript code below changes the PDF document being shown by the applet:
<script type="text/javascript">
var embedPDF=document.getElementById("embedPDF");
embedPDF.setPDF("example2.pdf");
</script>
The EmbedPDF applet provides the JavaScript API shown in the table below.
API |
Description |
|
setPDF(url) |
Loads a PDF document from the specified URL.
|
Copyright Notice
EmbedPDF Copyright
© 2008-2011 Werner Randelshofer
Hausmatt 10, CH-6405 Immensee, Switzerland
werner.randelshofer@bluewin.ch
http://www.randelshofer.ch
All rights reserved.
pdf-renderer Copyright © 2004-2010 Sun Microsystems
4150 Network Circle, Santa Clara, California 95054, U.S.A.
All rights reserved.
License Terms
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. See the GNU
Lesser General Public License for more details.
|