<!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: RTF generation settings</title><meta name="Description" content="How to configure settings for the RTF generation."><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>RTF generation settings</h2><div id="content"><div id="sidebar"><a class="toc" href="./../../index.html#rtf_documentsettings"> 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="#settings">RTF generation settings</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/documentsettings/DocumentSettings.java">DocumentSettings</a><br><div class="description">Generates a simple document with modified document settings</div><div class="small">Output:</div><ul><li><a href="http://itext.ugent.be/library/com/lowagie/examples/rtf/documentsettings/DocumentSettings.rtf">DocumentSettings.rtf</a></li></ul></div><div class="example"><div class="small">ANT script (all examples):</div><ul><li><a href="./../../rtf/documentsettings/build.xml"> build.xml </a></li></ul></div></div><div id="main"><a name="settings"></a><div class="title">RTF generation settings:</div><div xmlns="http://www.w3.org/1999/xhtml" xmlns:site="http://www.lowagie.com/iText/site"> The RtfWriter2 supports a set of configuration switches that can be used to tailor the RTF generated. <dl> <dt style="font-weight: bold;">outputTableRowDefinitionAfter (Boolean)</dt> <dd>Whether to write the table row definitions both before and after the table data. Set to <span class="commandline">true</span> if you are generating RTF documents that need to be read with Word 2000. Set to <span class="commandline">false</span> if you are generating RTF documents that need to be read with OpenOffice.org Writer. By default table row definitions are written both before and after.</dd> <dt style="font-weight: bold;">alwaysGenerateSoftLinebreaks (Boolean)</dt> <dd>Whether \n characters should be written as hard or soft linebreaks. By default only \n characters in lists and table cells are written as soft linebreaks. Setting this property to <span class="commandline">true</span> causes all \n characters to be written as soft linebreaks.s</dd> <dt style="font-weight: bold;">alwaysUseUnicode (Boolean)</dt> <dd>Whether all characters bigger than 'z' should be written as unicode escapes or whether the original character should be written. The default is to escape everything, which leads to larger RTF files. Setting this property to <span class="commandline">false</span> reduces RTF file size, but may lead to characters being displayed incorrectly.</dd> <dt style="font-weight: bold;">dataCacheStyle (Integer)</dt> <dd>Specifies where the RTF document is cached during document generation. Valid values are specified in the <a xmlns="" href="http://itext.ugent.be/library/api/com/lowagie/text/rtf/document/output/RtfDataCache.html">RtfDataCache</a>. <ul xmlns="http://www.w3.org/1999/xhtml"> <li>CACHE_MEMORY: The default keeps the whole document in memory. This increases the generation speed, but places a maximum size on the document.</li> <li>Cache_DISK: The document is cached on disk. This decreases the document generation speed, but the maximum document size is increased to the amount of space free on the disk.</li> </ul> You can only set this property before calling <span class="commandline">document.open()</span>. </dd> <dt style="font-weight: bold;">outputDebugLineBreaks (Boolean)</dt> <dd>This setting is primarily for debugging purposes and leads to slightly larger, but more readable RTF files. Set it to <span class="commandline">false</span> to decrease the RTF file size.</dd> </dl> You access these generation settings by getting the <span class="commandline">RtfDocumentSettings</span> object from the <span class="commandline">RtfWriter2</span>. <pre class="commandline"> Document document = new Document(); RtfWriter2 writer2 = RtfWriter2.getInstance(document, new FileOutputStream("rtfDocumentSettings.rtf")); // Access the RtfDocumentSettings and set the desired properties writer2.getRtfDocumentSettings().setDataCacheStyle(RtfDataCache.CACHE_DISK); document.open(); ... document.close(); </pre> <div id="example"> Example: java <a xmlns="" href="http://itext.ugent.be/library/com/lowagie/examples/rtf/documentsettings/DocumentSettings.java"> com.lowagie.examples.rtf.documentsettings.DocumentSettings</a><br>Generates a simple document with modified document settings: see <a href="http://itext.ugent.be/library/com/lowagie/examples/rtf/documentsettings/DocumentSettings.rtf">DocumentSettings.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:54 Copyright © 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=<1=_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=<1=&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=<1=&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>