Sophie

Sophie

distrib > Fedora > 17 > i386 > by-pkgid > cf79c2d0ed7fa2678c515072ee6f31e4 > files > 74

jasperreports-manual-4.0.2-4.fc17.noarch.rpm

<html xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://jasperreports.sourceforge.net/jasperreports">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JasperReports 4.0.2 - Markup Sample</title>
<style type="text/css">
.title {
	font-family: Arial, Verdana, Helvetica, sans-serif;
	font-size: 28px;
	font-weight: normal;
}

.toc {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.name {
	font-family: Courier New, Courier, serif;
	font-size: 16px;
	font-weight: bold;
}

.label {
	font-family: Arial, Verdana, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	font-style: italic;
}

.description {
	font-family: Arial, Verdana, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: normal;
}

.value {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.element {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.attribute {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: bold;
}

.code {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.copy {
	font-decoration: none;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 8pt;
	font-style: normal;
	color: #000000;
}

.subtitle {
	font-family: inherit;
	font-size: inherit;
	font-style: inherit;
	font-weight: bold;
	text-decoration: none;
	color: inherit;
}

</style>
</head>
<body bgcolor="#FFFFFF">
<a name="top"></a>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td colspan="2" align="right"><span class="element"><a href="../../sample.reference.html">Sample Reference</a> - <a href="../../schema.reference.html">Schema Reference</a> - <a href="../../config.reference.html">Configuration Reference</a> - <a href="http://jasperreports.sourceforge.net/api/index.html">API (Javadoc)</a></span>
<br>
</td>
</tr>
<tr>
<td colspan="2">
<hr size="1">
</td>
</tr>
<tr valign="middle">
<td nowrap="true"><span class="title">JasperReports - Markup Sample (version 4.0.2)</span></td><td align="right"><img src="../../resources/jasperreports.png" border="0"></td>
</tr>
<tr>
<td colspan="2">
<hr size="1">
</td>
</tr>
</table>
<br>
<span class="description"><span class="description">Shows how the text markup feature works in static and dynamic text elements.</span></span>
<br>
<br>
<span class="element"><a href="http://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%204.0.2/jasperreports-4.0.2-project.zip/download" target="_blank">Download All Sample Source Files</a></span>
<br>
<span class="element"><a href="http://jasperforge.org/scm/viewvc.php/tags/jr-4-0-2/jasperreports/demo/samples/markup/?root=jasperreports" target="_blank">Browse Sample Source Files on SVN</a></span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 20px;">
<br>
</td><td>
<br>
</td>
</tr>
<tr>
<td colspan="2"><span class="label">Main Features in This Sample</span></td>
</tr>
<tr>
<td>
<br>
</td><td><span class="element"><a href="#markup">Creating Styled Text Using a Markup Language</a></span></td>
</tr>
<tr>
<td colspan="2">
<br>
</td>
</tr>
<tr>
<td colspan="2"><span class="label">Secondary Features</span></td>
</tr>
<tr>
<td></td><td><span class="element"><a href="../styledtext/index.html#styledtext">Styled Text</a></span></td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td width="80%">
<br>
</td><td width="20%">
<br>
</td>
</tr>
<tr>
<td colspan="6" align="right"><a name="markup"></a><a href="#top" class="toc">top</a></td>
</tr>
<tr>
<td colspan="6">
<hr size="1">
</td>
</tr>
<tr valign="top">
<td><img src="../../resources/jr-16x16.png" border="0"></td><td colspan="4"><span class="name">Creating Styled Text Using a Markup Language</span></td><td align="right"><span class="copy">Documented by 
	<a href="mailto:shertage@users.sourceforge.net" class="copy">Sanda Zaharia</a></span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
<tr valign="top">
<td>
<br>
</td><td nowrap="true"><span class="label">Description / Goal</span></td><td>
<br>
</td><td colspan="3"><span class="description">
How to format text using a markup language such as HTML and/or RTF.
    </span></td>
</tr>
<tr valign="top">
<td>
<br>
</td><td colspan="1"><span class="label">Since</span></td><td>
<br>
</td><td colspan="3"><span class="description">2.0.5</span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
<tr>
<td>
<br>
</td><td colspan="5"><span class="description">
<b>Structured Text Content</b>

<br>

<br>
In order to achieve a particular look and feel, the text content in text elements can be 
customized with several style attributes such as text foreground color, text background color, 
font name, font size, font weight, etc. Some of these attributes (<span class="code"><code>forecolor</code></span>, 
<span class="code"><code>backcolor</code></span>) can be either set independently as report element attributes, or inherited from the 
<span class="code"><code>style</code></span> attribute. If set, these style attributes do affect all the text content in the 
report element.
<br>
But in some cases there is no need to apply a style to the entire text content. Users may want to 
highlight only few words within the text, without affecting the rest of the paragraph. There are 
situations when some words are needed in bold style, others require a specific font, and some characters 
have to be printed with a given color.
<br>
In such cases, the solution is to use specific  markup tags inside the text content, and to instruct the 
engine that the text content within the report element is no longer pure text, but structured XML content 
with specific processing rules. The XML content either includes style information in the
text itself, or some other form of markup language. 
<br> 

<br> 

<b>The <span class="code"><code>markup</code></span> Attribute</b>

<br>

<br>
Here comes the <span class="code"><code>markup</code></span> option attribute to accomplish its job. It specifies type of markup 
language that will be used inside the text element, and may have the following values:
<ul>

<li>
<span class="code"><code>none</code></span> - The content of the text element is plain text. There is nothing to be processed. This is the default value.</li>

<li>
<span class="code"><code>styled</code></span> - The content of the text element is styled text, the JasperReports proprietary XML type of markup text. 
It overrides the deprecated <span class="code"><code>isStyledText</code></span> attribute. (See the <a href="../styledtext/index.html" target="_blank" class="element">Styled text</a> sample)</li>

<li>
<span class="code"><code>html</code></span> - The content of the text element is Hyper Text Markup Language</li>

<li>
<span class="code"><code>rtf</code></span> - The content of the text element is Rich Text Format</li>

</ul> 
If the <span class="code"><code>html</code></span> or <span class="code"><code>rtf</code></span> values are set, then the engine calls a dedicated markup processor class based on the 
use of the <span class="code"><code>javax.swing.JEditorPane</code></span> processor. The structured XML fragment is parsed according to the 
processing rules, and its content gets formatted as included style attributes require to be.
<br> 

<br> 

<b>The Markup Sample</b>

<br>

<br>
This sample contains 3 structured text paragraphs. 
<br>
The first one is formatted using the <span class="code"><code>markup="styled"</code></span> value:
<br>

<pre>
	&lt;staticText&gt;
		&lt;reportElement mode="Opaque" x="0" y="0" width="555" height="140" backcolor="#c0c0c0"/&gt;
		&lt;textElement markup="styled"&gt;
			&lt;font size="16"/&gt;
		&lt;/textElement&gt;
		&lt;text&gt;&lt;![CDATA[This is a &lt;style isBold="true" isItalic="true" isUnderline="true"&gt;static text&lt;/style&gt; 
			element containing styled text. &lt;style backcolor="yellow" isBold="true" isItalic="true"&gt;Styled text&lt;/style&gt; 
			elements are introduced by setting the &lt;style forecolor="blue" isItalic="true"&gt;markup&lt;/style&gt; attribute 
			available for the &lt;style isBold="true" forecolor="magenta"&gt;textElement&lt;/style&gt; tag to 
			&lt;style forecolor="red" isItalic="true"&gt;styled&lt;/style&gt; and by formatting the text content using nested 
			&lt;style isBold="true" forecolor="green"&gt;style&lt;/style&gt; tags and simple HTML tags.&amp;#93;&amp;#93;&gt;
		&lt;/text&gt;
	&lt;/staticText&gt;
	</pre>
The second paragraph is read from the <span class="code"><code>rtf.txt</code></span> file in the /reports folder and stored in the <span class="code"><code>$P{RtfText}</code></span> parameter. 
Its content gets decoded using the RTF markup processor:
<pre>
	&lt;textField isStretchWithOverflow="true"&gt;
		&lt;reportElement mode="Opaque" x="0" y="150" width="555" height="140" backcolor="#c0c0c0" positionType="Float"/&gt;
		&lt;textElement markup="rtf"&gt;
			&lt;font size="16"/&gt;
		&lt;/textElement&gt;
		&lt;textFieldExpression&gt;$P{RtfText}&lt;/textFieldExpression&gt;
	&lt;/textField&gt;
	</pre>
The third paragraph is read from the <span class="code"><code>html.txt</code></span> file in the /reports folder and stored in the <span class="code"><code>$P{HtmlText}</code></span> parameter. 
Its content gets decoded using the HTML markup processor:
<pre>
	&lt;textField isStretchWithOverflow="true"&gt;
		&lt;reportElement mode="Opaque" x="0" y="300" width="555" height="140" backcolor="#c0c0c0" positionType="Float"/&gt;
		&lt;textElement markup="html"&gt;
			&lt;font size="16"/&gt;
		&lt;/textElement&gt;
		&lt;textFieldExpression&gt;$P{HtmlText}&lt;/textFieldExpression&gt;
	&lt;/textField&gt;
	</pre>

<b>Running the Sample</b>

<br>

<br>
Running the sample requires the <a href="http://ant.apache.org/" target="_blank" class="element">Apache Ant</a> library. Make sure that <span class="code"><code>ant</code></span> is already installed on your system (version 1.5 or later).
<br>
In a command prompt/terminal window set the current folder to <span class="code"><code>demo/samples/markup</code></span> within the JasperReports source project and run the <span class="code"><code>&gt; ant test view</code></span> command.
<br>
It will generate all supported document types containing the sample report in the <span class="code"><code>demo/samples/markup/build/reports</code></span> directory. 
<br>
Then the report will open in the JasperReports internal viewer.
    </span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
</table>
<br>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td>
<hr size="1">
</td>
</tr>
<tr>
<td align="center"><span class="copy">&copy; 2001-2010 Jaspersoft Corporation <a href="http://www.jaspersoft.com" target="_blank" class="copy">www.jaspersoft.com</a></span></td>
</tr>
</table>
</body>
</html>