Sophie

Sophie

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

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: Extended font support</title><meta name="Description" content="Extensions to the basic iText font system."><meta name="Keywords" content="JAVA, iText, RTF, examples"><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>Extended font support</h2><div id="content"><div id="sidebar"><a class="toc" href="./../../../index.html#rtf_extensions_font">
							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="#extendedfont">Extended font support</a></li><li><a href="#extendedfontstyles">Extended font styles</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/rtf/extensions/font/ExtendedFont.java">ExtendedFont</a><br><div class="description">Generates a simple document using the RtfFont class</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFont.rtf">ExtendedFont.rtf</a></li></ul></div><div class="example"><a class="source" href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFontStyles.java">ExtendedFontStyles</a><br><div class="description">Generates a simple document using the additional font styles in the RtfFont class</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFontStyles.rtf">ExtendedFontStyles.rtf</a></li></ul></div><div class="example"><div class="small">ANT script (all examples):</div><ul><li><a href="./../../../rtf/extensions/font/build.xml">
					build.xml
				</a></li></ul></div></div><div id="main"><a name="extendedfont"></a><div class="title">Extended font support:</div><div xmlns="http://www.w3.org/1999/xhtml" xmlns:site="http://www.lowagie.com/iText/site">
    	  iText provides a number of built-in fonts and these can be extended by embedding
    	  further fonts. Unfortunately embedding fonts is not supported in the RTF package
    	  and the <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/rtf/style/RtfFont.html">RtfFont</a>
    	  closes this gap.<br xmlns="http://www.w3.org/1999/xhtml"><br>
    	  
    	  The RtfFont extends the the basic iText <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/Font.html">Font</a>
    	  and can thus be used anywhere that the Font can be used. Using it is simple,
    	  you just specify the name of the font that you wish to use and then use the
    	  RtfFont like any other Font. The important thing is that the name of the font
    	  specified exactly matches the name of the font on the target system, otherwise
    	  it will not be used.
    	  
    	  <pre xmlns="http://www.w3.org/1999/xhtml" class="commandline">
// Create a RtfFont with the desired font name.
RtfFont msComicSans = new RtfFont("Comic Sans MS");
            
// Use the RtfFont like any other Font.
document.add(new Paragraph("This paragraph uses the" +
    " Comic Sans MS font.", msComicSans));
    	  </pre>
    	  
    	  The example above only demonstrates setting the font name, but there are also
    	  constructors with which you can specify font size, font style and colour.
    	  
    	  <div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFont.java">
						com.lowagie.examples.rtf.extensions.font.ExtendedFont</a><br>Generates a simple document using the RtfFont class: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFont.rtf">ExtendedFont.rtf</a><br></div>
    	  
    	  One thing to keep in mind when using the RtfFont is that the font is NOT embedded.
    	  This means that for it to be used when displaying the RTF document, the desired font
    	  has to be available on the system that displays the font. Whether the font is
    	  available on the system that generated the RTF document is irrelevant.
    	</div><a class="top" href="#top">Go to top of the page</a><a name="extendedfontstyles"></a><div class="title">Extended font styles:</div><div xmlns="http://www.w3.org/1999/xhtml">
    	  In addition to providing access to further font names, the
    	  <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/rtf/style/RtfFont.html">RtfFont</a>
    	  provides a number of additional font styles that can be used when generating
    	  RTF documents. These styles can be used in place of the styles provided by
    	  <a href="http://itext.ugent.be/library/api/com/lowagie/text/Font.html">Font</a> or combined with them.<br xmlns="http://www.w3.org/1999/xhtml"><br>
    	  
    	  The following extra styles are provides:<br>
    	  
		  <ul>
			<li>STYLE_DOUBLE_STRIKETHROUGH: A double strikethrough line.</li>
			<li>STYLE_SHADOW: Text with a shadow.</li>
			<li>STYLE_OUTLINE: Outlined text.</li>
			<li>STYLE_EMBOSSED: Embossed text.</li>
			<li>STYLE_ENGRAVED: Engraved text.</li>
			<li>STYLE_HIDDEN: Text that is initially hidden from user view.</li>
		  </ul>
		  
		  <pre class="commandline">
// Use the RtfFont.STYLE_* instead of the Font styles.
RtfFont doubleStrikethrough = new RtfFont("Arial", RtfFont.UNDEFINED,
    RtfFont.STYLE_DOUBLE_STRIKETHROUGH);

// Or combine them with Font styles.
RtfFont engravedItalic = new RtfFont("Arial", RtfFont.UNDEFINED,
    RtfFont.STYLE_ENGRAVED | Font.ITALIC);

// The hidden style is special since it hides text.
RtfFont hidden = new RtfFont("Arial", RtfFont.UNDEFINED,
    RtfFont.STYLE_HIDDEN);

Paragraph paragraph = new Paragraph("This text is ", new RtfFont("Arial", 12));
            
// Use the RtfFonts when creating the text.
paragraph.add(new Chunk("deleted,", doubleStrikethrough));
paragraph.add(new Chunk(" engraved and italic", engravedItalic));
paragraph.add(" and");
paragraph.add(new Chunk(" you won't see this", hidden));
paragraph.add(" nothing.");
            
document.add(paragraph);
		  </pre>
		  
		  <div id="example">
					Example: java
					<a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFontStyles.java">
						com.lowagie.examples.rtf.extensions.font.ExtendedFontStyles</a><br>Generates a simple document using the additional font styles in the RtfFont class: see
						 <a href="http://itext.ugent.be/library/com/lowagie/examples/rtf/extensions/font/ExtendedFontStyles.rtf">ExtendedFontStyles.rtf</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/10/05 21:25:50
			Copyright &copy; 1999-2005
			Mark Hall<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=0596004753&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/0596004753/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=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><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=RTF&=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>