Sophie

Sophie

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

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: Selected examples: EPS, TIFF, Barcodes</title><meta name="Description" content="Selected examples: Embedding PostScript, importing TIFF files, Barcodes"><meta name="Keywords" content="PDF, JAVA, iText, examples, tiff, eps, barcodes, PostScript, 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>Selected examples: EPS, TIFF, Barcodes</h2><div id="content"><div id="sidebar"><a class="toc" href="./../../../index.html#objects_images_tiff">
							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="#eps">Encapsulated PostScript</a></li><li><a href="#tiff">Tiff</a></li><li><a href="#barcode">Barcodes</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/images/tiff/EncapsulatedPostScript.java">EncapsulatedPostScript</a><br><div class="description">Adding EPS to PDF</div><div class="small">Input:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/parrot.ps">parrot.ps</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/tiger.ps">tiger.ps</a></li></ul><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/eps.pdf">eps.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/Tiff2Pdf.java">Tiff2Pdf</a><br><div class="description">Converts some tiff files to PDF</div><div class="small">Argument(s):</div><ul><li>12.tif</li><li>338814-00.tif</li><li>even.tif</li><li>odd.tif</li></ul><div class="small">Input:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/12.tif">12.tif</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/338814-00.tif">338814-00.tif</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/odd.tif">odd.tif</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/even.tif">even.tif</a></li></ul><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/12.pdf">12.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/338814-00.pdf">338814-00.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/even.pdf">even.pdf</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/odd.pdf">odd.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/OddEven.java">OddEven</a><br><div class="description">Combines 2 tiffs, one with odd, another with even pages into 1 combined PDF</div><div class="small">Argument(s):</div><ul><li>odd.tif</li><li>even.tif</li><li>combined.pdf</li></ul><div class="small">Input:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/odd.tif">odd.tif</a></li><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/even.tif">even.tif</a></li></ul><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/combined.pdf">combined.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/Barcodes.java">Barcodes</a><br><div class="description">List with different barcodes</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/barcodes.pdf">barcodes.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/ExampleEAN128.java">ExampleEAN128</a><br><div class="description">Example barcode ean128</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/ean128.pdf">ean128.pdf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/ExamplePDF417.java">ExamplePDF417</a><br><div class="description">Example barcode pdf417</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/pdf417.pdf">pdf417.pdf</a></li></ul></div><div class="example"><div class="small">ANT script (all examples):</div><ul><li><a href="./../../../objects/images/tiff/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=5">
				Chapter 5:
			</a>Inserting images</li></ul></p>
		</div><a class="top" href="#top">Go to top of the page</a><a name="eps"></a><div class="title">Encapsulated PostScript:</div><div xmlns="http://www.w3.org/1999/xhtml">
Since version 1.2.4 of iText, it's possible to add EPS images into your document (as a com.lowagie.text.Image).
EPS is an extension of the PostScript graphics file format developed by Adobe Systems.
Support in iText for this format is very basic, but it should be useful for simple logos.
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/EncapsulatedPostScript.java">
						com.lowagie.examples.objects.images.tiff.EncapsulatedPostScript</a><br>Adding EPS to PDF: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/eps.pdf">eps.pdf</a><br>
						External resources for this example:
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/parrot.ps">parrot.ps</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/tiger.ps">tiger.ps</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="tiff"></a><div class="title">Tiff:</div><div xmlns="http://www.w3.org/1999/xhtml">
iText also supports TIFF. TIFF is the Tagged Image File Format.
It was developed in 1986 by an industry committee chaired by the
Aldus Corporation (now part of Adobe). Microsoft and Hewlett-Packard
were also on the committee. It is unique in that it incorporates
multiple compression techniques, allowing the user to specify
the best format for a type of image, and that one file can contain
multiple images. TIFFs are common in desktop publishing,
faxing, and medical imaging applications.<br>
The examples below can be used as standalone tools.
Tiff2Pdf converts a TIFF file into a PDF file.
If the TIFF has more than one image, a PDF with more than one page will be generated.
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/Tiff2Pdf.java">
						com.lowagie.examples.objects.images.tiff.Tiff2Pdf</a> 12.tif 338814-00.tif even.tif odd.tif<br>Converts some tiff files to PDF: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/12.pdf">12.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/338814-00.pdf">338814-00.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/even.pdf">even.pdf</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/odd.pdf">odd.pdf</a><br>
						External resources for this example:
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/12.tif">12.tif</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/338814-00.tif">338814-00.tif</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/odd.tif">odd.tif</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/even.tif">even.tif</a><br></div>
The OddEven example was inspired by a <a xmlns="http://www.w3.org/1999/xhtml" href="http://sourceforge.net/projects/tifftools/">tiffmesh example</a>,
which is part of another SourceForge library <a href="http://sourceforge.net/projects/tifftools/">TiffTools</a>.
Tiffmesh is a utility to mesh together two TIFF files containing odd and even pages into one big TIFF file.
So if you use a scanner to scan in text from double-sided pages, you can scan the odd pages into one tiff
and the even pages into another one. With Tiffmesh you can knit both files together into one tiff.
With the OddEven-example/tool, you can do the same to combine both files into one PDF document.
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/OddEven.java">
						com.lowagie.examples.objects.images.tiff.OddEven</a> odd.tif even.tif combined.pdf<br>Combines 2 tiffs, one with odd, another with even pages into 1 combined PDF: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/combined.pdf">combined.pdf</a><br>
						External resources for this example:
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/odd.tif">odd.tif</a> <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/even.tif">even.tif</a><br></div>
</div><a class="top" href="#top">Go to top of the page</a><a name="barcode"></a><div class="title">Barcodes:</div><div xmlns="http://www.w3.org/1999/xhtml">iText also comes with a number of classes that generate barcodes.
The following types are supported:
<ul>
<li><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode39.html">Barcode39:</a> code 39 and code 39 extended</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode128.html">Barcode128:</a>
<ul xmlns="http://www.w3.org/1999/xhtml">
<li><b>CODE128</b> - plain barcode 128.</li>
<li><b>CODE128_UCC</b> - support for UCC/EAN-128 with a full list of AI.</li>
<li><b>CODE128_RAW</b> - raw mode. The code attribute has the actual codes from 0 to 105 followed by '\uffff' and the human readable text.</li>
</ul></li>
<li><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/BarcodeEAN.html">BarcodeEAN:</a> EAN13, EAN8, UPCA, UPCE, and EAN with supplemental 5, EAN with supplemental 5, EAN with supplemental 2</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/BarcodeEANSUPP.html">BarcodeEANSUPP:</a> takes 2 barcodes, an EAN/UPC and a supplemental</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/BarcodeInter25.html">BarcodeInter25:</a> interleaved 2 of 5</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/BarcodePostnet.html">BarcodePostnet:</a> postnet and planet</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/BarcodePDF417.html">BarcodePDF417:</a> the 2D barcode PDF417</li>
<li xmlns="http://www.w3.org/1999/xhtml"><a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/BarcodeCodabar.html">BarcodeCodabar:</a> codabar</li>
</ul>
This is an code example to generate an EAN-barcode with value 9780201615883:
<pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">PdfContentByte cb = writer.getDirectContent();
BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCodeType(codeEAN.EAN13);
codeEAN.setCode("9780201615883");
Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);
document.add(new Phrase(new Chunk(imageEAN, 0, 0)));</pre>
<div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/Barcodes.java">
						com.lowagie.examples.objects.images.tiff.Barcodes</a><br>List with different barcodes: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/barcodes.pdf">barcodes.pdf</a><br></div>
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/ExampleEAN128.java">
						com.lowagie.examples.objects.images.tiff.ExampleEAN128</a><br>Example barcode ean128: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/ean128.pdf">ean128.pdf</a><br></div>
<div id="example">
					Example: java
					<a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/ExamplePDF417.java">
						com.lowagie.examples.objects.images.tiff.ExamplePDF417</a><br>Example barcode pdf417: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/objects/images/tiff/pdf417.pdf">pdf417.pdf</a><br></div>
All barcode classes implement the abstract class
<a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode.html">Barcode</a>.
Please read the API documentation to see the defaults for every specific barcode type,
and for the different methods to change the 'look' of the barcode.
To add a barcode to a document with iText, convert it to an Image or PdfTemplate object
using <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode.html#createImageWithBarcode(com.lowagie.text.pdf.PdfContentByte,%20java.awt.Color,%20java.awt.Color)">createImageWithBarcode(com.lowagie.text.pdf.PdfContentByte, java.awt.Color, java.awt.Color)</a>
or <a href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode.html#createTemplateWithBarcode(com.lowagie.text.pdf.PdfContentByte,%20java.awt.Color,%20java.awt.Color)">createTemplateWithBarcode(com.lowagie.text.pdf.PdfContentByte, java.awt.Color, java.awt.Color)</a>.
The colors specify the color of the bars and text are:
<table xmlns="http://www.w3.org/1999/xhtml" border="1">
<tr>
<th>barColor</th>
<th>textColor</th>
<th>Result</th>
</tr>
<tr>
<td>null</td>
<td>null</td>
<td>bars and text painted with current fill color</td>
</tr>
<tr>
<td>barColor</td>
<td>null</td>
<td>bars and text painted with barColor</td>
</tr>
<tr>
<td>null</td>
<td>textColor</td>
<td>bars painted with current color<br>text painted with textColor</td>
</tr>
<tr>
<td>barColor</td>
<td>textColor</td>
<td>bars painted with barColor<br>text painted with textColor</td>
</tr>
</table>
If you want a barcode without any text, just set the font to <span class="commandline">null</span>
with <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode.html#setFont(com.lowagie.text.pdf.BaseFont)">setFont(com.lowagie.text.pdf.BaseFont)</a>
<br xmlns="http://www.w3.org/1999/xhtml">
Note that you also can create a textless java.awt.Image of the barcode object with
<a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/pdf/Barcode.html#createAwtImage(java.awt.Color,%20java.awt.Color)">createAwtImage(java.awt.Color, java.awt.Color)</a>.
</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:52
			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=0201379228&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/0201379228/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=0201101793&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/0201101793/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=0943779502&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/0943779502/catloogjecom-21" class="amazonlinks">
			amazon.co.uk-link
		</a><br><br></div></body></html>