Sophie

Sophie

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

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 - No Page Break 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 - No Page Break 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 reports can be designed and exported in a way that hides the existence of page breaks.</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/nopagebreak/?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="#nopagebreak">Suppress Pagination</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="nopagebreak"></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">Suppress Pagination</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 suppress pagination in generated documents.
    </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">1.0.1</span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
<tr>
<td>
<br>
</td><td colspan="5"><span class="description">
<b>The <span class="code"><code>isIgnorePagination</code></span> Flag</b>

<br>

<br>
Usually JasperReports generates page-oriented document layouts: each document is a collection of 
pages having the same width, height, and page orientation. However, if needed, multiple documents with particular  
page settings can be concatenated to produce a single document output with different page layouts, using 
the <a href="../batchexport/index.html" target="_blank" class="element">batch export</a> facility.
<br>

<br>
In the case where no batch export is implied, all document pages share the same page settings, and they are 
by default separated by page breaks. At export time each exporter has its own way to handle the page break 
element in order to make visible the page separation.
<br>
But there are situations, especially for web-oriented applications, where pagination is irrelevant and 
it causes the document to be displayed improperly. For instance, when exporting documents to HTML format, 
one might prefer to display it as a continuous scrollable page rather than a succession of pages separated 
by visible empty spaces. Or, when exporting to Excel in a single sheet document, a layout without visible 
page breaks would be preferred.
<br>

<br>
This is why the engine needs to be instructed how to handle page breaks in various situations. A possibility 
would be to completely ignore the pagination, with no respect to the output document format. Responsible for 
this kind of approach is the <span class="code"><code>isIgnorePagination</code></span> flag property. It can be found among the 
<span class="code"><code>&lt;jasperReport/&gt;</code></span> element attributes:
<br>

<br>

<span class="code"><code> 
 &lt;jasperReport ... isIgnorePagination="true" ...&gt;
<br>
 ...
<br>
 &lt;/jasperReport&gt;
</code></span> 

<br>

<br>
When <span class="code"><code>isIgnorePagination</code></span> is set to <span class="code"><code>true</code></span>, the report-filling engine will 
generate the document on a single, very long page. Running the generated report to any output format, 
a single page document will be visualized.
<br>
While this is the desired behavior for some document types, such as HTML, XML or XLS, it's quite uncomfortably 
for documents with page-oriented layout (like PDF, DOCX, etc) to be displayed as single very long pages, without the 
possibility to navigate between pages. 
<br>

<br>
By default, <span class="code"><code>isIgnorePagination</code></span> is set to <span class="code"><code>false</code></span>. For various purposes this flag can be 
overriden at report filling time using the optional built-in 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRParameter.html#IS_IGNORE_PAGINATION" target="_blank">IS_IGNORE_PAGINATION</a></span> parameter. 
<br>

<br>

<b>Handling Page Breaks at Export Time</b>

<br>

<br>
When <span class="code"><code>isIgnorePagination</code></span> is <span class="code"><code>true</code></span> the report will be generated in a single page. 
And this layout will be irreversible. The resulting page can no more be fragmented back into multiple sections 
at runtime.
<br>

<br>
Therefore, using a <span class="code"><code>isIgnorePagination="true"</code></span> attribute works properly if the report will be definitely 
printed out in flow-oriented document layouts. In the case of multiple output document layout, the best choice is 
to let the pagination being handled at export time, each exporter providing its own handling mode.
<br>
In order to accomplish this, one have to let the <span class="code"><code>isIgnorePagination</code></span> with its default value 
(ie <span class="code"><code>false</code></span>). At fill time the document will be generated as multiple pages document. Then, at export time, 
the exporter could decide whether to print out the document as multipage, or to concatenate all pages into a single one, 
by suppressing all empty space between pages.
<br>

<br>

<b>Handling Page Breaks with HTML Exporter</b>

<br>

<br>
When a multipage document gets exported into HTML format there are three possibilities to configure its layout:
<ul>

<li>The document will be printed out page by page; only a single document page can be visualized at a time; one can navigate between pages using a navigation bar script.</li>

<li>All document pages will be printed out in a sequence where page breaks appear as noticeable amount of empty space on the vertical axis. Sometimes this is not a very 
user-friendly webpage and removing the extra blank space between pages is required. In such a case a lot of help comes from the 
<span class="code"><code>net.sf.jasperreports.export.html.remove.emtpy.space.between.rows</code></span> hint property (or the associated 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRHtmlExporterParameter.html#IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS" target="_blank">IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS</a></span> export parameter). 
If this property is <span class="code"><code>true</code></span>, then all empty rows in the generated HTML table will be collapsed, leading to a completely flow-oriented layout. 
By default, the exporter preserves all the whitespace for pixel-perfect page layouts.</li> 

<li>All document pages will be printed out in a sequence where page breaks appear as a custom HTML separator. One can replace the default blank space between pages with 
a customized separator element (a horizontal line, for example). The HTML code fragment for the custom separator can be set using the 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRHtmlExporterParameter.html#BETWEEN_PAGES_HTML" target="_blank">BETWEEN_PAGES_HTML</a></span> export parameter.</li>

</ul>

<b>Handling Page Breaks with XLS Exporters</b>

<br>

<br>
JasperReports provides several dedicated exporters to export documents in Excel formats. All of them generate Excel-compatible documents organized as workbooks which store inside 
one or more separated sheets. Because Excel documents are collections of sheets, one can consider that usually an Excel sheet is equivalent to a document page, 
and each XLS exporter should be able to translate a page content into an equivalent sheet content.
<br>

<br>
Like in HTML, there are multiple possibilities to handle sheet breaks when exporting to Excel format:
<ul>

<li>The document will be printed as one page per sheet; each page will be printed out on a separate sheet in the workbook. This setting can be done using the 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXlsAbstractExporterParameter.html#PROPERTY_ONE_PAGE_PER_SHEET" target="_blank">PROPERTY_ONE_PAGE_PER_SHEET</a></span> exporter 
hint property (or the equivalent 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXlsAbstractExporterParameter.html#IS_ONE_PAGE_PER_SHEET" target="_blank">IS_ONE_PAGE_PER_SHEET</a></span> export parameter). If this 
property is <span class="code"><code>true</code></span> then one page per sheet will be printed out. By default this property is set to <span class="code"><code>false</code></span>.
</li>

<li>When <span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXlsAbstractExporterParameter.html#PROPERTY_ONE_PAGE_PER_SHEET" target="_blank">PROPERTY_ONE_PAGE_PER_SHEET</a></span> is not set, 
all document pages will be printed out into a single sheet. Page breaks appear as supplementary empty rows between pages. Like in HTML, the 
<span class="code"><code>net.sf.jasperreports.export.html.remove.emtpy.space.between.rows</code></span> hint property (or the associated 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXlsAbstractExporterParameter.html#IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS" target="_blank">IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS</a></span> export parameter) 
becomes very useful. 
<br>
If this property is <span class="code"><code>true</code></span>, then all empty rows in the generated sheet will be collapsed, leading to a completely flow-oriented layout. 
However, by default the property is <span class="code"><code>false</code></span>. The exporter preserves by default all the whitespace for pixel-perfect layouts.</li> 

<li>Another specific sheet-related feature (therefore available only for XLS exporters) is that any sheet can be broken into multiple sheet children, 
all of them having the same maximum number of rows. For instance, if a generated sheet contains 1234 rows, it can be broken into 3 sheets with maximum 600 rows. 
The first 2 sheets contain 600 rows each, and the third contains the remaining 34 rows. In this case, even the fill-time 
<span class="code"><code>isIgnorePagination</code></span> flag is <span class="code"><code>true</code></span>, it is still possible at export time to get multiple sheets starting with a single one, by limiting the 
maximum number of rows per sheet. This can be done using the 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXlsAbstractExporterParameter.html#PROPERTY_MAXIMUM_ROWS_PER_SHEET" target="_blank">PROPERTY_MAXIMUM_ROWS_PER_SHEET</a></span> 
(or the associated 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRXlsAbstractExporterParameter.html#MAXIMUM_ROWS_PER_SHEET" target="_blank">MAXIMUM_ROWS_PER_SHEET</a></span> export parameter).</li>

</ul>

<br>

<br>

<b>Suppress Pagination Examples</b>

<br>

<br>
This sample works with the default value for the <span class="code"><code>isIgnorePagination</code></span> flag, which means that the document will be generated into separate pages. 
Then, when the document gets exported, some exporters are instructed to suppress the pagination in specific ways.
<br>

<br>
In the NoPageBreakApp.java one can see how the export parameters responsible for page breaks handling are set.
<br>

<br>
For the HTML exporter (see the <span class="code"><code>html()</code></span> method):
<pre>
  exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
  exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);</pre>
And for XLS and XLSX exporters (see <span class="code"><code>xls()</code></span> and <span class="code"><code>xlsx()</code></span> methods)
<pre>
  exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
  exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);</pre>
For comparison, the <span class="code"><code>IS_ONE_PAGE_PER_SHEET</code></span> parameter was set to <span class="code"><code>true</code></span> for the JExcelApi exporter (see the <span class="code"><code>jxl()</code></span> method):
<pre>
  exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
  exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);</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/hsqldb</code></span> within the JasperReports source project and run the <span class="code"><code>&gt; ant runServer</code></span> command. 
It will start the HSQLDB server shipped with the JasperReports distribution package. Let this terminal running the HSQLDB server.  
<br>
Open a new command prompt/terminal window and set the current folder to <span class="code"><code>demo/samples/charts</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/charts/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>