Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 927a1532fb070c51449654bb68b5bde2 > files > 415

itext-manual-2.0.8-0.0.2mdv2008.1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>iText Tutorial: Anchors, Actions and Annotations</title><meta name="Description" content="Deals with all the RemoteGoto, LocalGoto, Action, Annotation,... functionality"><meta name="Keywords" content="PDF, JAVA, iText, examples, anchors, remoteGoto, LocalGoto, Actions, Annotations, Lowagie, Bruno"><link rel="stylesheet" href="./../../style.css" type="text/css"></head><body><a name="top" class="logo" href="http://www.lowagie.com/iText"><img src="http://www.lowagie.com/iText/images/logo.gif" border="0" alt="iText"></a><h1>Tutorial: iText by Example</h1><h2>Anchors, Actions and Annotations</h2><div id="content"><div id="sidebar"><a class="toc" href="./../../index.html#objects_anchors">
							Table of Contents
						</a><div align="Center" class="small">Best viewed with:<br><script type="text/javascript"><!--
google_ad_client = "pub-0340380473790570";
google_ad_width = 180;
google_ad_height = 60;
google_ad_format = "180x60_as_rimg";
google_cpa_choice = "CAAQyaj8zwEaCIwcWMzeycafKMu293M";
//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><div class="sidetitle">Sections:</div><ul><li><a href="#inaction">In the book</a></li><li><a href="#localgoto">Local Goto and Local Destination</a></li><li><a href="#remotegoto">Remote Goto</a></li><li><a href="#anchor">the Anchor object</a></li><li><a href="#actions">Actions</a></li><li><a href="#annotation">Annotations</a></li></ul><br><br><div class="sidetitle">Examples:</div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalGoto.java">LocalGoto</a><br><div class="description">Creates a document with a local goto and a local destination</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalGoto.pdf">LocalGoto.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalDestination.java">LocalDestination</a><br><div class="description">Creates a document that jumps to a local destination upon opening</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalDestination.pdf">LocalDestination.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/RemoteGoto.java">RemoteGoto</a><br><div class="description">Creates two documents with links to eachother and to an external URL</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/DocumentA.pdf">DocumentA.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/DocumentB.pdf">DocumentB.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/AHref.java">AHref</a><br><div class="description">Using the Anchor object</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/AHref.pdf">AHref.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/AHref.html">AHref.html</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/NamedActions.java">NamedActions</a><br><div class="description">Creates a document with named actions.</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/NamedActions.pdf">NamedActions.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/JavaScriptAction.java">JavaScriptAction</a><br><div class="description">Creates a document with a Javascript action.</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/JavaScriptAction.pdf">JavaScriptAction.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Actions.java">Actions</a><br><div class="description">Creates a document with some goto actions</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Actions.pdf">Actions.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/remote.pdf">remote.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/ChainedActions.java">ChainedActions</a><br><div class="description">Creates a document with chained actions.</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/ChainedActions.pdf">ChainedActions.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/OpenApplication.java">OpenApplication</a><br><div class="description">Creates a document with a link to open an external application.</div><div class="small">Argument(s):</div><ul><li>C://windows/</li></ul><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/OpenApplication.pdf">OpenApplication.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/SimpleAnnotations.java">SimpleAnnotations</a><br><div class="description">Creates two documents with different types of annotations</div><div class="small">Input:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/cards.mpg">cards.mpg</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/iText.gif">iText.gif</a></li></ul><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/SimpleAnnotations1.pdf">SimpleAnnotations1.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/SimpleAnnotations2.pdf">SimpleAnnotations2.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Annotations.java">Annotations</a><br><div class="description">Creates a document with some PdfAnnotations</div><div class="small">Input:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/cards.mpg">cards.mpg</a></li></ul><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Annotations.pdf">Annotations.pdf</a></li></ul></div><div class="example"><div class="small">ANT script (all examples):</div><ul><li><a href="./../../objects/anchors/build.xml">
					build.xml
				</a></li></ul></div></div><div id="main"><a name="inaction"></a><div class="title">In the book:</div><div xmlns="http://www.w3.org/1999/xhtml" xmlns:site="http://www.lowagie.com/iText/site">
		<p xmlns=""><a href="http://itext.ugent.be/itext-in-action/"><img src="http://itext.ugent.be/img/lowagie_3d.jpg" border="0" align="right"></a>
			The examples in this free online tutorial will help you getting started
			with iText. Note that most examples are two years old.
			Some of the examples may be obsolete. Also the theory that
			comes with the examples isn't always 100% accurate.
			If you want more recent examples or if you want to know more
			about the theoretical background of	PDF and iText, please consult the book
			<a href="http://itext.ugent.be/itext-in-action/">
				"iText in Action".
			</a>
			Note that the first and the third chapter of the book
			can be downloaded for free from <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=223_53">http://manning.com/lowagie/</a></p><p>
			More specifically:
			<ul><li><a class="subtitle" href="http://itext.ugent.be/itext-in-action/chapter.php?chapter=4">
				Chapter 4:
			</a>Composing text elements</li><li><a class="subtitle" href="http://itext.ugent.be/itext-in-action/chapter.php?chapter=13">
				Chapter 13:
			</a>Browsing a PDF document</li><li><a class="subtitle" href="http://itext.ugent.be/itext-in-action/chapter.php?chapter=15">
				Chapter 15:
			</a>Creating annotations and fields</li></ul></p>
		</div><a class="top" href="#top">Go to top of the page</a><a name="localgoto"></a><div class="title">Local Goto and Local Destination:</div><div xmlns="http://www.w3.org/1999/xhtml">
Sometimes you need a link to allow the reader of your document to jump from one position (LocalGoto) in the text to another (LocalDestination).
You can achieve this with two methods of class Chunk: <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/Chunk.html#setLocalGoto(java.lang.String)">setLocalGoto</a> and <a href="http://itext.ugent.be/library/api/com/lowagie/text/Chunk.html#setLocalDestination(java.lang.String)">setLocalDestination</a>.
Both methods take 1 parameter: this is the unique name you want to give to the destination.
<pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">new Chunk("localgoto").setLocalGoto("test");
new Chunk("localdestination").setLocalDestination("test");</pre>
The HTML equivalent of the first line is <span class="commandline">&lt;A HREF="#test"&gt;localgoto&lt;A&gt;</span>;
The equivalent of the second is <span class="commandline">&lt;A NAME="test"&gt;localdestination&lt;A&gt;</span>.
However if we want to produce HTML (with <a xmlns="" href="./../../html/index.html#">HtmlWriter</a>), we will use the <a href="./../../objects/anchors/index.html#anchor">Anchor object</a>.
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalGoto.java">
						com.lowagie.examples.objects.anchors.LocalGoto</a><br>Creates a document with a local goto and a local destination: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalGoto.pdf">LocalGoto.pdf</a><br></div>
A LocalGoto-chunk isn't the only way to reach a LocalDestination.
As you will see later on in this chapter and in the chapter on <a href="./../../objects/bookmarks/index.html#">bookmarks</a>, local destinations can be used in actions too.
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalDestination.java">
						com.lowagie.examples.objects.anchors.LocalDestination</a><br>Creates a document that jumps to a local destination upon opening: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalDestination.pdf">LocalDestination.pdf</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="remotegoto"></a><div class="title">Remote Goto:</div><div xmlns="http://www.w3.org/1999/xhtml">
If you have defined a local destination in a certain document (see <a xmlns="" href="./../../objects/anchors/index.html#localgoto">above</a>),
you can jump to this destination from another document. This is done with the method
<a href="http://itext.ugent.be/library/api/com/lowagie/text/Chunk.html#setRemoteGoto(java.lang.String,%20java.lang.String)">setRemoteGoto(String filename, String name)</a>.
You don't necessarily need a local destination in the other document. You can also jump to a certain page with<a href="http://itext.ugent.be/library/api/com/lowagie/text/Chunk.html#setRemoteGoto(java.lang.String,%20int)">setRemoteGoto(String filename, int page)</a>.
<pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">new Chunk("go to a destination in document B")
	.setRemoteGoto("DocumentB.pdf", "test");
new Chunk("go to page 3 in document B")
	.setRemoteGoto("DocumentB.pdf", 3);</pre>
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/RemoteGoto.java">
						com.lowagie.examples.objects.anchors.RemoteGoto</a><br>Creates two documents with links to eachother and to an external URL: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/DocumentA.pdf">DocumentA.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/DocumentB.pdf">DocumentB.pdf</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="anchor"></a><div class="title">the Anchor object:</div><div xmlns="http://www.w3.org/1999/xhtml">
There as some alternative ways to add external links such as <span class="commandline">&lt;A HREF="http://www.lowagie.com/iText/"&gt;Bruno's site&lt;A&gt;</span>
or internal links such as <span class="commandline">&lt;A NAME="top"&gt;top of the page&lt;A&gt;</span> and
<span class="commandline">&lt;A HREF="#top"&gt;goto top&lt;A&gt;</span>.
One of them is using the <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/Anchor.html">Anchor object</a>.
This is a very simple class and the beauty of it is that it works, not only in PDF, but also in HTML and RTF.<br xmlns="http://www.w3.org/1999/xhtml">
This is the code to create an external link:
<pre>Anchor anchor = new Anchor("website");
anchor.setReference("http://www.lowagie.com/iText/");
anchor.setName("website");</pre>
This is the code for an internal link:
<pre>Anchor anchor1 = new Anchor("This is an internal link");
anchor1.setName("link1");
Anchor anchor2 = new Anchor("Go to the internal link");
anchor.setReference("#link1");</pre>
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/AHref.java">
						com.lowagie.examples.objects.anchors.AHref</a><br>Using the Anchor object: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/AHref.pdf">AHref.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/AHref.html">AHref.html</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="actions"></a><div class="title">Actions:</div><div xmlns="http://www.w3.org/1999/xhtml">
A PDF document can have a certain interactivity: you can create several 'actions',
for instance to jump to another page or location,
to start an other application, to invoke a JavaScript function,...
In the next subsections, some actions that are supported in iText will be explained; see the javadocs (<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/PdfAction.html">class PdfAction</a>) for more types of actions.
Note that many of the action can be constructed in two alternative ways: with the constructor or with a static method that calls the constructor.<br xmlns="http://www.w3.org/1999/xhtml"><br>
<div class="subtitle">Named Actions</div>
There are 5 predefined named actions in iText:
<ul>
<li>PdfAction.<b>FIRSTPAGE</b>: jumps to the first page</li>
<li>PdfAction.<b>PREVPAGE</b>: jumps to the previous page</li>
<li>PdfAction.<b>NEXTPAGE</b>: jumps to the next page</li>
<li>PdfAction.<b>LASTPAGE</b>: jumps to the last page</li>
<li>PdfAction.<b>PRINTDIALOG</b>: opens a PrintDialog</li>
</ul>
It is very easy to use one of these named destinations:
<pre class="commandline">new Chunk("First Page")
	.setAction(new PdfAction(PdfAction.FIRSTPAGE));</pre>
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/NamedActions.java">
						com.lowagie.examples.objects.anchors.NamedActions</a><br>Creates a document with named actions.: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/NamedActions.pdf">NamedActions.pdf</a><br></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="subtitle">JavaScript</div>
Acrobat JavaScript is a programming language based
on the JavaScript, aka ECMAScript, originally developed by Netscape Communications.
Acrobat JavaScript adds new objects, methods and properties to the JavaScript language.
These Acrobat-specific objects can allow you to handle file attachments, manage
document security, perform form manipulations, etc, etc...<br>
Acrobat JavaScript does not have access to objects within an HTML page and
HTML JavaScript cannot access objects within a PDF file. For instance: Acrobat JavaScript cannot access the Window object
(e.g. the browser window in which the Acrobat plugin is embedded).<br>
You will have to read the Acrobat JavaScript Scripting Reference (Adobe Inc.)
and the Client-Side JavaScript Reference (Netscape Communications Corporation);
these documents and other JavaScript guides and references are available through
the Adobe Web pages <a href="http://partners.adobe.com/NSjscript/">http://partners.adobe.com/NSjscript/</a>
and <a href="http://partners.adobe.com/public/developer/acrobat/sdk/index_doc.html#js">http://partners.adobe.com/public/developer/acrobat/sdk/index_doc.html</a>.
<pre class="commandline">new Chunk("Click to say Hello")
	.setAction(
		PdfAction.javaScript("app.alert('Hello');\r", writer));</pre>
The code above, adds an alert action to a Chunk. If you click the text in the Chunk,
an alert is triggered with the message 'Hello'.
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/JavaScriptAction.java">
						com.lowagie.examples.objects.anchors.JavaScriptAction</a><br>Creates a document with a Javascript action.: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/JavaScriptAction.pdf">JavaScriptAction.pdf</a><br></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="subtitle">Goto Actions</div>
If you want to jump to another document or URL, as yet another alternative way
to do what we did in the previous sections, you can create a PdfAction
using one of the following constructors:
<ul>
<li><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#PdfAction(java.lang.String,%20java.lang.String)">PdfAction(String filename, String name)</a></li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#PdfAction(java.lang.String,%20int)">PdfAction(String filename, int page)</a></li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#PdfAction(java.net.URL)">PdfAction(URL url)</a></li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#PdfAction(java.lang.String)">PdfAction(String url)</a></li>
</ul>
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#gotoLocalPage(int,%20com.lowagie.text.pdf.PdfDestination,%20com.lowagie.text.pdf.PdfWriter)">PdfAction.gotoLocalPage(int page, PdfDestination dest, PdfWriter writer)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#gotoLocalPage(java.lang.String,%20boolean)">PdfAction.gotoLocalPage(String dest, boolean isName)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#gotoRemotePage(java.lang.String,%20java.lang.String,%20boolean,%20boolean)">PdfAction.gotoRemotePage(String filename, String dest, boolean isName, boolean newWindow)</a>
are the alternative static methods to construct Goto actions.<br xmlns="http://www.w3.org/1999/xhtml">
<span class="commandline">PdfAction.gotoRemotePage("remote.pdf", "test", false, true)</span>
creates an action that goes to the destination "test" in remote.pdf in a new window.<br>
<img xmlns="" border="0" src="./../../images/newwindow.gif" alt="Open Action New Window"><br xmlns="http://www.w3.org/1999/xhtml">
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Actions.java">
						com.lowagie.examples.objects.anchors.Actions</a><br>Creates a document with some goto actions: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Actions.pdf">Actions.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/remote.pdf">remote.pdf</a><br></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="subtitle">Open Actions</div>
We've already used an 'Open Action' twice.
In the previous example with the method <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfWriter.html#setOpenAction(com.lowagie.text.pdf.PdfAction)">setOpenAction(PdfAction action)</a>
and in an earlier example with the method <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfWriter.html#setOpenAction(java.lang.String)">setOpenAction(String name)</a>:
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalDestination.java">
						com.lowagie.examples.objects.anchors.LocalDestination</a><br>Creates a document that jumps to a local destination upon opening: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/LocalDestination.pdf">LocalDestination.pdf</a><br></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="subtitle">Chained Actions</div>
If you want to trigger two or more actions after eachother, you can chain them using
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#next(com.lowagie.text.pdf.PdfAction)">next(PdfAction action)</a>.
<pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">PdfAction action = PdfAction.javaScript("app.alert('Welcome');\r", writer);
action.next(new PdfAction("http://www.lowagie.com/iText/"));</pre>
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/ChainedActions.java">
						com.lowagie.examples.objects.anchors.ChainedActions</a><br>Creates a document with chained actions.: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/ChainedActions.pdf">ChainedActions.pdf</a><br></div>
<div xmlns="http://www.w3.org/1999/xhtml" class="subtitle">Launching an Application</div>
You can open an application from a PDF file using a Launch Action.
Be careful: this is a very platformdependent feature and it isn't very safe to use.
Read the Javadocs on method <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#PdfAction(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)">PdfAction(String application, String parameters, String operation, String defaultDir)</a>
for more information concerning the parameters. In the example below, we launch NOTEPAD (only on Windows, change the param if WINROOT does not equal C://windows/).
<pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">new Chunk("Click to open NOTEPAD")
	.setAction(new PdfAction("C://WINDOWS/notepad.exe", null, null, null));</pre>
The alternative static method to construct this Action is
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAction.html#createLaunch(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)">PdfAction.createLaunch(String application, String parameters, String operation, String defaultDir)</a>
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/OpenApplication.java">
						com.lowagie.examples.objects.anchors.OpenApplication</a> C://windows/<br>Creates a document with a link to open an external application.: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/OpenApplication.pdf">OpenApplication.pdf</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="annotation"></a><div class="title">Annotations:</div><div xmlns="http://www.w3.org/1999/xhtml">
Yes, using Annotations is yet another alternative to jump to a specific local or remote destination.
Lets take a look at some simple things you can do with the class <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/Annotation.html">Annotation</a>
<ul xmlns="http://www.w3.org/1999/xhtml">

<li>
<b>Text:</b> you can add small pieces of text to your document that are not
really part of the content. Annotations have a title and some content.
<pre class="commandline">Annotation a = new Annotation(
	"authors",
	"Maybe it's because I wanted to be an author myself that I wrote iText.",
	100f, 700f, 200f, 800f);</pre>
</li>

<li>
<b>External links:</b> you have to specify a clickable rectangle and a String (representing the URL) or an URL-object.
<pre class="commandline">Annotation annot = new Annotation(
	100f, 700f, 200f, 800f,
	new URL("http://www.lowagie.com/iText/"));
Annotation annot = new Annotation(
	100f, 700f, 200f, 800f,
	"http://www.lowagie.com/iText");</pre>
</li>

<li><b>External PDF file:</b> you have to specify a clickable rectangle and a String (the filename) and a destination or pagenumber.
<pre class="commandline">Annotation annot = new Annotation(
	100f, 700f, 200f, 800f,	"other.pdf", "mark");
Annotation annot = new Annotation(
	100f, 700f, 200f, 800f,	"other.pdf", 2);</pre>
</li>

<li><b>Named action:</b> you have to specify a clickable rectangle and a named action:
<pre class="commandline">Annotation annot = new Annotation(
	100f, 700f, 200f, 800f, PdfAction.FIRSTPAGE);</pre>
</li>

<li><b>Application:</b> you have to specify a clickable rectangle and an application:
<pre class="commandline">Annotation annot = new Annotation(
	300f, 700f, 400f, 800f,
	"C://windows/notepad.exe", null, null, null);</pre>
</li>
<li>
<b>Media Clip:</b> you can specify a rectangle and a movie file and its MIMETYPE. You also need to specify if the clips needs to be shown on display of the page (since PDF 1.5).
<pre class="commandline">new Annotation(200f, 700f, 300f, 800f, "cards.mpg", "video/mpeg", true);</pre>
</li>

</ul>
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/SimpleAnnotations.java">
						com.lowagie.examples.objects.anchors.SimpleAnnotations</a><br>Creates two documents with different types of annotations: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/SimpleAnnotations1.pdf">SimpleAnnotations1.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/SimpleAnnotations2.pdf">SimpleAnnotations2.pdf</a><br>
						External resources for this example:
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/cards.mpg">cards.mpg</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/iText.gif">iText.gif</a><br></div>
As an alternative for using the <a href="http://itext.ugent.be/library/api/com/lowagie/text/Annotation.html#constructor_summary">Annotation constructors</a>,
you can use the constructor in <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAnnotation.html#PdfAnnotation(com.lowagie.text.pdf.PdfWriter,%20float,%20float,%20float,%20float,%20com.lowagie.text.pdf.PdfAction)">class PdfAnnotation</a>.
As you can pass any action to this constructor, you have a more options than with class <a href="http://itext.ugent.be/library/api/com/lowagie/text/Annotation.html">Annotation</a>.
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfAnnotation.html">PdfAnnotation</a> also has lots of static methods that allow you to create specific annotations.
In the example below some more complex features are presented using the constructor and static methods
of PdfAnnotation, but keep in mind that some of these features only work since PDF version 1.5.
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Annotations.java">
						com.lowagie.examples.objects.anchors.Annotations</a><br>Creates a document with some PdfAnnotations: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/Annotations.pdf">Annotations.pdf</a><br>
						External resources for this example:
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/anchors/cards.mpg">cards.mpg</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><div id="footer" xmlns="http://www.w3.org/1999/xhtml">
			Page Updated: 2006/09/17 10:13:50
			Copyright &copy; 1999-2005
			Bruno Lowagie<br><a href="http://www.lowagie.com/iText/">iText</a> is a Free Java-Pdf library by Bruno Lowagie and Paulo Soares.
		</div></div></div><div class="commercial"><br><script type="text/javascript"><!--
google_ad_client = "pub-0340380473790570";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_channel ="";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "1B09BD";
google_color_url = "100670";
google_color_text = "707070";
//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><br><br><div class="subtitle">Amazon books:</div><script type="text/javascript"><!--
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=itisacatalofwebp&o=1&p=8&l=as1&asins=1932394796&fc1=000000&lc1=0000ff&bc1=&lt1=_blank&IS2=1&bg1=ffffff&f=ifr" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" align="Center"></iframe>');
//--></script><a xmlns="" href="http://www.amazon.co.uk/exec/obidos/ASIN/1932394796/catloogjecom-21" class="amazonlinks">
			amazon.co.uk-link
		</a><br><br><script type="text/javascript"><!--
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=itisacatalofwebp&o=1&p=8&l=as1&asins=0321304748&fc1=000000&lc1=0000ff&bc1=&lt1=_blank&IS2=1&bg1=ffffff&f=ifr" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" align="Center"></iframe>');
//--></script><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0321304748/catloogjecom-21" class="amazonlinks">
			amazon.co.uk-link
		</a><br><br><script type="text/javascript"><!--
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=itisacatalofwebp&o=1&p=8&l=as1&asins=0321305310&fc1=000000&lc1=0000ff&bc1=&lt1=_blank&IS2=1&bg1=ffffff&f=ifr" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" align="Center"></iframe>');
//--></script><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0321305310/catloogjecom-21" class="amazonlinks">
			amazon.co.uk-link
		</a><br><br><script type="text/javascript"><!--
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=itisacatalofwebp&o=1&p=8&l=as1&asins=3540608540&fc1=000000&lc1=0000ff&bc1=&lt1=_blank&IS2=1&bg1=ffffff&f=ifr" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" align="Center"></iframe>');
//--></script><a href="http://www.amazon.co.uk/exec/obidos/ASIN/3540608540/catloogjecom-21" class="amazonlinks">
			amazon.co.uk-link
		</a><br><br><script type="text/javascript"><!--
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=itisacatalofwebp&o=1&p=10&l=st1&mode=books&search=PDF&=1&fc1=&lc1=&lt1=&bg1=&f=ifr" width="120" height="460" border="0" frameborder="0" style="border:none;" scrolling="no" marginwidth="0" marginheight="0"></iframe>');
//--></script><br><script type="text/javascript"><!--
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=itisacatalofwebp&o=1&p=10&l=st1&mode=books&search=JAVA&=1&fc1=&lc1=&lt1=&bg1=&f=ifr" width="120" height="460" border="0" frameborder="0" style="border:none;" scrolling="no" marginwidth="0" marginheight="0"></iframe>');
//--></script><br></div></body></html>