Sie zeigen eine alte Version dieser Seite an. Zeigen Sie die aktuelle Version an.

Unterschiede anzeigen Seitenhistorie anzeigen

Version 1 Nächste Version anzeigen »

globe with meridians Language: Deutsch · English

open book Formatting

Formatting recipes for JasperReports – bold, number formats, frames/addresses, hyperlinks, markup and line breaks.

REFERENZ APPLICATION DEVELOPER STAND: JUL 2026 GILT FUER NUCLOS 4.2026.X

Auf dieser Seite

Bold & italic

The bold flag only affects the designer preview – the PDF is not changed. For real bold/italic printing choose the proper font (even though the property is shown struck through).

Choosing bold/italic via the font.

Decimals in a text field

Field content in JasperReports is defined by one Java statement. For formatted decimals:

new java.text.DecimalFormat("#,###,##0.00", java.text.DecimalFormatSymbols.getInstance($P{REPORT_LOCALE})).format($F{betrag})

English number format (workaround)

Numbers inside text cannot be formatted automatically. For an English format this hack helps:

new java.text.DecimalFormat("#,##0.00").format($V{zwsumme}.doubleValue()).replace(",", "x").replace(".", ",").replace("x", ".")

Continuous vertical column lines

Via Padding and Borders of a text field a line can be shown per side. For the line to grow with the column, the fields must not have a fixed height (see Stretch with overflow).

Stretch with overflow – uniform display

When a field grows beyond its width, neighbouring fields shift. Fix:

  1. Select all text fields → right-click → Padding And BordersPadding Top: 4px.
  2. Set the field height to 0px.
  3. Set the lower field to Position Type = Float and Position Top = 0 (like all others).

After upload all fields line up.

Frames with addresses

A frame is a container for further elements (also nested). For an address block the Title band is suitable (first page only); for envelopes leave enough page margin (approx. 50px).

Merge two fields into one address line and remove empty lines:

  1. In the Text Field Expression dialog concatenate the fields with + (string concatenation), returning null when a value is missing.
  2. On the field set the flags RemoveLineWhenBlank, BlankWhenNull and StretchWithOverflow.

Empty lines (e.g. strstrassezusatz) are then removed automatically and the rest are pushed together.

Address block: text field expression.

Link a text field or image – either via the context menu (Hyperlink, type Reference) or directly in the JRXML:

<textField hyperlinkType="Reference">
   		<reportElement mode="Transparent" x="137" y="14" width="133" height="14"/>
		<textElement>
			<font size="11"/>
		</textElement>
		<textFieldExpression class="java.lang.String">"www.nuclos.de"</textFieldExpression>
		<hyperlinkReferenceExpression>"http://www.nuclos.de"</hyperlinkReferenceExpression>
</textField>

Markup – styled

With markup you format individual words/paragraphs inside a text field without adding a new field. Set the property markup = styled and use <style> tags:

<style isBold='true' pdfFontName='Helvetica-Bold'  >Das ist ein dicker Text </style><style isBold='true' pdfFontName='Helvetica-Bold'  size='20'>20 Pixel groß </style><style isItalic='true' isUnderline='true' forecolor='green'> Grüner Text unterstzrichen und schief </style><style isBold='true' pdfFontName='Helvetica-Bold'  size='12'>&#38; hallo ich bin ein Sonderzeichen</style>

Special character &

Markup fails if the text contains a &. Replace it beforehand with the entity: attribute.replaceAll("&", "&amp;"). Replace other special characters via their UTF-8 sequence if needed.

Line break in markup

A <br/> in the text produces a line break (field still markup = styled). Example: concatenate a result set in Oracle via LISTAGG() with <br/>:

SELECT listagg(T2x."STRBEZEICHNUNG",'<br/>') 
    within group (order by T2x."STRBEZEICHNUNG") "strtext"
    
    FROM 
    Tabelle T1x
        
        WHERE 
        (
        T1x."Tabelle T1x" = Parameter
        )) "strtext",

Min height to start new page

This property specifies the space already used by other components (not the height of the current element) from which a new page break starts.

Related pages

printer Creating forms with Jaspersoft Studio


Forms.

Öffnen →

open book Inserting images


Images.

Öffnen →

clipboard Tips and tricks


More tips.

Öffnen →

  • Keine Stichwörter