Sophie

Sophie

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

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: Graphics State</title><meta name="Description" content="Add graphics directly to the PDF file using the PdfContentByte class."><meta name="Keywords" content="PDF, JAVA, iText, examples, PdfContentByte, Graphics, 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>Graphics State</h2><div id="content"><div id="sidebar"><a class="toc" href="./../../index.html#directcontent_graphics">
							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="#pdfsyntax">PDF Syntax</a></li><li><a href="#state">Graphics State</a></li><li><a href="#parameters">Methods to change the parameters</a></li><li><a href="#paths">Path construction and painting</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/directcontent/graphics/Literal.java">Literal</a><br><div class="description">Writing PDF Syntax directly to iText</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/literal.pdf">literal.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/State.java">State</a><br><div class="description">Changing the Graphics State with saveState and restoreState</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/state.pdf">state.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/GState.java">GState</a><br><div class="description">Changing the Graphics State with setGState</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/gstate.pdf">gstate.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/Circles.java">Circles</a><br><div class="description">Draws some concentric circles</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/circles.pdf">circles.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/Shapes.java">Shapes</a><br><div class="description">Draws some shapes</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/shapes.pdf">shapes.pdf</a></li></ul></div><div class="example"><div class="small">ANT script (all examples):</div><ul><li><a href="./../../directcontent/graphics/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=10">
				Chapter 10:
			</a>Constructing and painting paths</li></ul></p>
		</div><a class="top" href="#top">Go to top of the page</a><a name="pdfsyntax"></a><div class="title">PDF Syntax:</div><div xmlns="http://www.w3.org/1999/xhtml">
PDF Syntax looks like this:
<pre class="commandline">0.3 g
15.000 27.000 m
7.947 5.292 l
26.413 18.708 l
3.587 18.708 l
22.053 5.292 l
f
45.000 57.000 m
37.947 35.292 l
56.413 48.708 l
33.587 48.708 l
52.053 35.292 l
f
0.7 g
15.000 57.000 m
7.947 35.292 l
26.413 48.708 l
3.587 48.708 l
22.053 35.292 l
f
45.000 27.000 m
37.947 5.292 l
56.413 18.708 l
33.587 18.708 l
52.053 5.292 l
f</pre>
The example above draws 4 little stars in 2 different grayscales in the lower left corner of your page.
You could write all this syntax by hand, there's even some methods
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLiteral(String)">PdfContentByte.setLiteral</a>
that allow you to do this in iText, but trust me: that's not an easy job. If you want to write a complete PDF file from scratch,
you also need to know a lot about the byte position of every object.
I have set compression to false in the first example, so you can read the PDF file with a plain text editor,
just to convince you, you really shouldn't start writing PDFs manually.
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/Literal.java">
						com.lowagie.examples.directcontent.graphics.Literal</a><br>Writing PDF Syntax directly to iText: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/literal.pdf">literal.pdf</a><br></div>
The PDF syntax of the example can be generated using simple iText methods such as
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setGrayFill(float)">setGrayFill(float)</a> (the lines ending with g),
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#moveTo(float,%20float)">moveTo(float, float)</a> (the lines ending with m),
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#lineTo(float,%20float)">lineTo(float, float)</a> (the lines ending with l)
and <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#fill()">fill()</a> (the f).<br xmlns="http://www.w3.org/1999/xhtml">
All these methods are described in this chapter.
</div><a class="top" href="#top">Go to top of the page</a><a xmlns="" name="state"></a><div class="title">Graphics State:</div><div xmlns="http://www.w3.org/1999/xhtml">
The graphics state is initialized at the beginning of each page.
All parameters, such as current color (one for filling and one for stroking),
current line width, current dash pattern,... have default values.
When using iText, you can change most of these defaults with methods in class
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html">PdfContentByte</a>.
Some of the parameters can only be changed with the
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html">PdfGState</a> object,
which is a special <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfDictionary.html">PdfDictionary</a>
(the Graphics State dictionary).<br xmlns="http://www.w3.org/1999/xhtml"><br>
The Graphics State is stored in a stack. If you need to change the Graphics State,
you can save the current state with
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#saveState()">PdfContentByte.saveState()</a>
and return to that state later on with
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#restoreState()">PdfContentByte.restoreState()</a>.
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/State.java">
						com.lowagie.examples.directcontent.graphics.State</a><br>Changing the Graphics State with saveState and restoreState: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/state.pdf">state.pdf</a><br></div>
In the example, we first draw a circle with a radius of 250pts and
we see how the default fill-color is black.
<pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">cb.circle(260.0f, 500.0f, 250.0f);
cb.fill();
</pre>
We save this state and change the
fill-color to red.
<pre class="commandline">cb.saveState();
cb.setColorFill(Color.red);
cb.circle(260.0f, 500.0f, 200.0f);
cb.fill();
</pre>
The circle with a radius of 200pts is drawn in red. We save
this second state and change the fill-color to blue.
<pre class="commandline">cb.saveState();
cb.setColorFill(Color.blue);
cb.circle(260.0f, 500.0f, 150.0f);
cb.fill();
</pre>
The circle with radius 150pts is drawn in red. We restore the state to the second state (with fill-color red).
<pre class="commandline">cb.restoreState();
cb.circle(260.0f, 500.0f, 100.0f);
cb.fill();
</pre>
As you can see, the circle with radius 100pts is drawn in red. Than we restore the
original state and the circle with radius 50pts is drawn in black.
<pre class="commandline">cb.restoreState();
cb.circle(260.0f, 500.0f, 50.0f);
cb.fill();
</pre>
Note that the saveState and restoreState must be balanced.
An exception will be thrown if you try to restore a graphics state before
you have called saveState.<br><br>
The next example shows you how to use the
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html">PdfGState</a> object
to change the state.
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/GState.java">
						com.lowagie.examples.directcontent.graphics.GState</a><br>Changing the Graphics State with setGState: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/gstate.pdf">gstate.pdf</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="parameters"></a><div class="title">Methods to change the parameters:</div><div xmlns="http://www.w3.org/1999/xhtml">
Tables 4.2 and 4.3 in the PDF Reference Manual (section 4.3) give you all the available graphic
state parameters. In the following tables, I sum up all these parameters and I'll
add the methods that can be used in iText to change their values (if such
a method is available).<br><br>
<div class="subtitle">Device-independent graphics state parameters</div>
<table border="1" width="100%">
<tr>
<td class="small" valign="top">CTM</td>
<td>When you are adding an Image or a PdfTemplate, you will in some cases also add the
(a, b, c, d, e, f) values for the transformation matrix. The meaning of these values will
be explained elsewhere in this tutorial.</td>
</tr>
<tr>
<td class="small" valign="top">clipping path</td>
<td>Methods <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#clip()">clip()</a>
and <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#eoClip()">eoClip()</a>
can be used to clip output.</td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">color space</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setDefaultColorspace(com.lowagie.text.pdf.PdfName,%20com.lowagie.text.pdf.PdfObject)">setDefaultColorspace(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject)</a><br xmlns="http://www.w3.org/1999/xhtml">
Note that the different setColor methods change the colorspace automatically.
Please go to the chapter on <a xmlns="" href="./../../directcontent/colors/index.html#">colors</a> for more info and some examples.</td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">color</td>
<td>
<b>RGB colors (device dependent!):</b><br>
These methods change the color space to DeviceRGB automatically:
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setRGBColorFill(int,%20int,%20int)">setRGBColorFill(int, int, int)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setRGBColorFillF(float,%20float,%20float)">setRGBColorFillF(float, float, float)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#resetRGBColorFill()">resetRGBColorFill()</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setRGBColorStroke(int,%20int,%20int)">setRGBColorStroke(int, int, int)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setRGBColorStrokeF(float,%20float,%20float)">setRGBColorStrokeF(float, float, float)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#resetRGBColorStroke()">resetRGBColorStroke()</a><br xmlns="http://www.w3.org/1999/xhtml">
Methods that take integers as parameter, usually expect a value between 0x00 and 0xFF.
Methods that take a float, expect a value between 0f and 1f. (default = black)<br>
<b>CMYK colors (device dependent):</b><br>
These methods change the color space to DeviceCMYK automatically:
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setCMYKColorFill(int,int,%20int,%20int)">setCMYKColorFill(int, int, int, int)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setCMYKColorFillF(float,%20float,%20float,%20float)">setCMYKColorFillF(float, float, float, float)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#resetCMYKColorFill()">resetCMYKColorFill()</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setCMYKColorStroke(int,%20int,%20int,%20int)">setCMYKColorStroke(int, int, int, int)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setCMYKColorStrokeF(float,%20float,%20float,%20float)">setCMYKColorStrokeF(float, float, float, float)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#resetCMYKColorStroke()">resetCMYKColorStroke()</a><br xmlns="http://www.w3.org/1999/xhtml">
<b>Grayfill:</b><br>
These methods change the color space to DeviceGray automatically (= the default):
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setGrayFill(float)">setGrayFill(float)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#resetGrayFill()">resetGrayFill()</a>.<br xmlns="http://www.w3.org/1999/xhtml">
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setGrayStroke(float)">setGrayStroke(float)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#resetGrayStroke()">resetGrayStroke()</a>.
float is a value between 0 (black) and 1 (white)<br xmlns="http://www.w3.org/1999/xhtml">
<b>Spotcolors (device independent):</b><br>
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setColorFill(com.lowagie.text.pdf.PdfSpotColor,%20float)">setColorFill(com.lowagie.text.pdf.PdfSpotColor, float)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setColorStroke(com.lowagie.text.pdf.PdfSpotColor,%20float)">setColorStroke(com.lowagie.text.pdf.PdfSpotColor, float)</a><br xmlns="http://www.w3.org/1999/xhtml">
<b>Extended Color:</b><br>
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setColorFill(java.awt.Color)">setColorFill(java.awt.Color)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setColorStroke(java.awt.Color)">setColorStroke(java.awt.Color)</a><br xmlns="http://www.w3.org/1999/xhtml">
Please go to the chapter on <a xmlns="" href="./../../directcontent/colors/index.html#">colors</a> for more info and some examples.
</td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">text state</td>
<td>See the chapter on text.</td>
</tr>
<tr>
<td class="small" valign="top">line width</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineWidth(float)">setLineWidth(float)</a><br xmlns="http://www.w3.org/1999/xhtml">
The parameter represents the thickness of the line (default = 1).</td>
</tr>
<tr>
<td class="small" valign="top">line cap</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineCap(int)">setLineCap(int)</a><br xmlns="http://www.w3.org/1999/xhtml">
The parameter can be <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#LINE_CAP_BUTT">PdfContentByte.LINE_CAP_BUTT</a> (default),
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#LINE_CAP_ROUND">PdfContentByte.LINE_CAP_ROUND</a>
or <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#LINE_CAP_PROJECTING_SQUARE">PdfContentByte.LINE_CAP_PROJECTING_SQUARE</a>.</td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">line join</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineJoin(int)">setLineJoin(int)</a><br xmlns="http://www.w3.org/1999/xhtml">
The parameter can be <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#LINE_JOIN_MITER">PdfContentByte.LINE_JOIN_MITER</a> (default),
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#LINE_JOIN_ROUND">PdfContentByte.LINE_JOIN_ROUND</a>
or <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#LINE_JOIN_BEVEL">PdfContentByte.LINE_JOIN_BEVEL</a>.</td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">miter limit</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setMiterLimit(float)">setMiterLimit(float)</a><br xmlns="http://www.w3.org/1999/xhtml">
The parameter is a limit for joining lines, when exceeded, the join is converted from a miter to a bevel.</td>
</tr>
<tr>
<td class="small" valign="top">dash pattern</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineDash(float)">setLineDash(float)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineDash(float[],%20float)">setLineDash(float[], float)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineDash(float,%20float)">setLineDash(float, float)</a> or
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setLineDash(float,%20float,%20float)">setLineDash(float, float, float)</a>.<br xmlns="http://www.w3.org/1999/xhtml">
The parameters describe a <i>dash pattern</i> (default = a solid line).</td>
</tr>
<tr>
<td class="small" valign="top">rendering intent</td>
<td>Used internally when rendering PNG Images.</td>
</tr>
<tr>
<td class="small" valign="top">stroke adjustment</td>
<td>not implemented in iText</td>
</tr>
<tr>
<td class="small" valign="top">blend mode</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#setBlendMode(com.lowagie.text.pdf.PdfName)">setBlendMode(com.lowagie.text.pdf.PdfName)</a><br xmlns="http://www.w3.org/1999/xhtml">
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_NORMAL">PdfGState.BM_NORMAL</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_COMPATIBLE">PdfGState.BM_COMPATIBLE</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_MULTIPLY">PdfGState.BM_MULTIPLY</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_SCREEN">PdfGState.BM_SCREEN</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_OVERLAY">PdfGState.BM_OVERLAY</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_DARKEN">PdfGState.BM_DARKEN</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_LIGHTEN">PdfGState.BM_LIGHTEN</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_COLORDODGE">PdfGState.BM_COLORDODGE</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_COLORBURN">PdfGState.BM_COLORBURN</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_HARDLIGHT">PdfGState.BM_HARDLIGHT</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_SOFTLIGHT">PdfGState.BM_SOFTLIGHT</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_DIFFERENCE">PdfGState.BM_DIFFERENCE</a> or
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#BM_EXCLUSION">PdfGState.BM_EXCLUSION</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">soft mask</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/Image.html#makeMask()">Image.makeMask()</a>
and <a href="http://itext.ugent.be/library/api/com/lowagie/text/Image.html#setImageMask(com.lowagie.text.Image)">Image.setImageMask(com.lowagie.text.Image)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">alpha constant</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#setFillOpacity(float)">setFillOpacity(float)</a>
and <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#setStrokeOpacity(float)">setStrokeOpacity(float)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">alpha source</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#setAlphaIsShape(boolean)">setAlphaIsShape(boolean)</a></td>
</tr>
</table>
<br xmlns="http://www.w3.org/1999/xhtml"><br>

<div class="subtitle">Device-dependent graphics state parameters</div>
<table border="1" width="100%">
<tr>
<td class="small" valign="top">overprint</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#setOverPrintStroking(boolean)">setOverPrintStroking(boolean)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfGState.html#setOverPrintNonStroking(boolean)">setOverPrintNonStroking(boolean)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">overprint mode</td>
<td>not implemented</td>
</tr>
<tr>
<td class="small" valign="top">black generation</td>
<td>not implemented</td>
</tr>
<tr>
<td class="small" valign="top">undercolor removal</td>
<td>not implemented</td>
</tr>
<tr>
<td class="small" valign="top">transfer</td>
<td>not implemented</td>
</tr>
<tr valign="top">
<td class="small">halftone</td>
<td>not implemented</td>
</tr>
<tr>
<td class="small" valign="top">flatness</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#setFlatness(float)">setFlatness(float)</a><br xmlns="http://www.w3.org/1999/xhtml">
The parameter is a distance in device pixels.</td>
</tr>
<tr>
<td class="small" valign="top">smootness</td>
<td>not implemented</td>
</tr>
</table>
</div><a class="top" href="#top">Go to top of the page</a><a xmlns="" name="paths"></a><div class="title">Path construction and painting:</div><div xmlns="http://www.w3.org/1999/xhtml">
<br>
<div class="subtitle">construction</div>
Section 4.4 of the PDF Reference Manual deals with paths (p194):
<blockquote>Paths define shapes, trajectories and regions of all sorts.
They are used to draw lines, define the shapes of filled areas,
and specify boundaries for clipping other graphics.</blockquote>
Table 4.9 in the reference manual gives you an overview of the path construction operators.
In the following table, I sum up all these operators with their corresponding method in
the iText class <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html">PdfContentByte</a>.
<table xmlns="http://www.w3.org/1999/xhtml" border="1" width="100%">
<tr>
<td class="small" valign="top">m</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#moveTo(float,%20float)">moveTo(float, float)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">l</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#lineTo(float,%20float)">lineTo(float, float)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">c</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#curveTo(float,%20float,%20float,%20float,%20float,%20float)">curveTo(float, float, float, float, float float)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">v</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#curveTo(float,%20float,%20float,%20float)">curveTo(float, float, float, float)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">y</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#curveFromTo(float,%20float,%20float,%20float)">curveFromTo(float, float, float, float)</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">h</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#closePath()">closePath()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">re</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#rectangle(float,%20float,%20float,%20float)">rectangle(float, float, float, float)</a>
</td>
</tr>
</table>
For more info on these methods (especially the curveTo-ones), please read the
PDF Reference Manual section 4.4.1 or consult the API documentation.<br xmlns="http://www.w3.org/1999/xhtml">
For ease of use, some extra methods were added in iText:
<ul>
<li><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#circle(float,%20float,%20float)">circle(float, float, float)</a>,
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#ellipse(float,%20float,%20float,%20float)">ellipse(float, float, float, float)</a> and
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#arc(float,%20float,%20float,%20float,%20float,%20float)">arc(float, float, float, float, float, float)</a>
allow you to draw some specific curves.</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#rectangle(com.lowagie.text.Rectangle)">rectangle(com.lowagie.text.Rectangle)</a> not only draws
the rectangle as is done with <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#rectangle(float,%20float,%20float,%20float)">rectangle(float, float, float, float)</a>,
but also fills it with colors and takes into account some other attributes of class <a href="http://itext.ugent.be/library/api/com/lowagie/text/Rectangle).html">com.lowagie.text.Rectangle</a>.<br xmlns="http://www.w3.org/1999/xhtml">
The same goes for <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#variableRectangle(com.lowagie.text.Rectangle)">variableRectangle(com.lowagie.text.Rectangle)</a></li>
</ul>
<br xmlns="http://www.w3.org/1999/xhtml">
<div class="subtitle">painting</div>
It is very important to understand that constructing a path doesn't paint the path!
When you construct a path, the PDF interpreter doesn't know what you plan to do with it.
If you want to paint it, you will have to use a path painting operator.
These operators are listed in Table 4.10 of the Reference manual.
Again I will sum them up with their corresponding iText method.
<table border="1" width="100%">
<tr>
<td class="small" valign="top">S</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#stroke()">stroke()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">s</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#closePathStroke()">closePathStroke()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">f</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#fill()">fill()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">F</td>
<td>not used (as described in the reference manual).</td>
</tr>
<tr>
<td class="small" valign="top">f*</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#eoFill()">eoFill()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">B</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#fillStroke()">fillStroke()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">B*</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#eoFillStroke()">eoFillStroke()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">b</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#closePathFillStroke()">closePathFillStroke()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">b*</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#closePathEoFillStroke()">closePathEoFillStroke()</a></td>
</tr>
<tr xmlns="http://www.w3.org/1999/xhtml">
<td class="small" valign="top">n</td>
<td><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/PdfContentByte.html#newPath()">newPath()</a></td>
</tr>
</table><br xmlns="http://www.w3.org/1999/xhtml">
<div class="subtitle">Using PdfContentByte</div>
These are some simple examples demonstrating some of the methods mentioned above:
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/Shapes.java">
						com.lowagie.examples.directcontent.graphics.Shapes</a><br>Draws some shapes: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/shapes.pdf">shapes.pdf</a><br></div>
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/Circles.java">
						com.lowagie.examples.directcontent.graphics.Circles</a><br>Draws some concentric circles: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/directcontent/graphics/circles.pdf">circles.pdf</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:51
			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=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=PostScript&=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=Graphics&=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>