> For the complete documentation index, see [llms.txt](https://docs.servoy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.servoy.com/guides/develop/programming-guide/jasperreports/jasperreportsservoyviewer.md).

# Jaspe Reports Viewer

(beans.jasperReportsServoyViewer)

## Overview

The `JasperReportsServoyViewer` is a Servoy bean designed to embed and display JasperReports within Servoy applications. It provides scripting capabilities for customizing visual properties such as background, foreground, font, size, and borders. The bean integrates with the `JasperReportsProvider` to support dynamic report viewing and customization. ## Functionality Reports can be rendered and displayed using the `js_showReport` method, which accepts parameters such as data source, report file, and locale. The viewer supports various export formats, configurable through scripting. The bean also facilitates managing paths for report directories and extra resource directories, ensuring integration with the JasperReports plugin. The `JRViewer` wrapper enables fine-tuned control of the viewer’s display behavior and export functionality.

## Properties Summarized

| Type                                                       | Name                                                  | Summary                                                                                                                                                                        |
| ---------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [background](#background)                             | Sets or gets the background color of the Bean.                                                                                                                                 |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [beanVersion](#beanversion)                           | This is a readonly property which returns the bean version.                                                                                                                    |
| [Array](/reference/servoycore/dev-api/js-lib/array.md)     | [beanViewerExportFormats](#beanviewerexportformats)   | Gets or gets the file save/export formats of the Bean's viewer.                                                                                                                |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [border](#border)                                     | Sets or gets the border type, width and color.                                                                                                                                 |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [displayMode](#displaymode)                           |                                                                                                                                                                                |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [font](#font)                                         | Sets or gets the font type of the Bean's viewer.                                                                                                                               |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [foreground](#foreground)                             | Sets or gets the foreground color.                                                                                                                                             |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [name](#name)                                         | Gets or sets the name of the Bean.                                                                                                                                             |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [relativeExtraDirectories](#relativeextradirectories) | Get or set the relative path or comma separated paths to the extra resource directories of the Servoy JasperReports plugin.                                                    |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [relativeReportsDirectory](#relativereportsdirectory) | Property for retrieving and setting the path to the reports directory, set by the current client, relative to the server reports directory of the Servoy JasperReports plugin. |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [transparent](#transparent)                           |                                                                                                                                                                                |

## Methods Summarized

| Type                                                     | Name                                                                                                                                             | Summary                                                             |
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
| [Number](/reference/servoycore/dev-api/js-lib/number.md) | [getHeight()](#getheight)                                                                                                                        | Gets the height of the Bean.                                        |
| [Number](/reference/servoycore/dev-api/js-lib/number.md) | [getLocationX()](#getlocationx)                                                                                                                  | Gets the x-coordinate of the Bean's top-left corner location.       |
| [Number](/reference/servoycore/dev-api/js-lib/number.md) | [getLocationY()](#getlocationy)                                                                                                                  | Gets the y-coordinate of the Bean's top-left corner location.       |
| [Number](/reference/servoycore/dev-api/js-lib/number.md) | [getWidth()](#getwidth)                                                                                                                          | Gets the width of the Bean.                                         |
| void                                                     | [setLocation(x, y)](#setlocation-x-y)                                                                                                            |                                                                     |
| void                                                     | [setSize(width, height)](#setsize-width-height)                                                                                                  | Sets the size of the Bean.                                          |
| void                                                     | [showReport(source, report, parameters)](#showreport-source-report-parameters)                                                                   | Shows the indicated report in a JasperReports Viewer (in the Bean). |
| void                                                     | [showReport(source, report, parameters, localeString)](#showreport-source-report-parameters-localestring)                                        | Shows the indicated report in a JasperReports Viewer (in the Bean). |
| void                                                     | [showReport(source, report, parameters, localeString, moveTableOfContent)](#showreport-source-report-parameters-localestring-movetableofcontent) | Shows the indicated report in a JasperReports Viewer (in the Bean). |

## Properties Detailed

### background

Sets or gets the background color of the Bean.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the border color of the bean

**Sample**

```js
myElement.background='#00ff00';
```

### beanVersion

This is a readonly property which returns the bean version.\
The bean version indicates which version of the Servoy JasperReports plugin the bean should be used with.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the version of the bean; this should be in sync with the version of the plugin used

**Sample**

```js
application.output(myElement.beanVersion);
```

### beanViewerExportFormats

Gets or gets the file save/export formats of the Bean's viewer.

**Type**\
[Array](/reference/servoycore/dev-api/js-lib/array.md) the file save/export formats of the viewer

**Sample**

```js
//also see plugins.jasperReports.viewerExportFormats
myElement.beanViewerExportFormats=[OUTPUT_FORMAT.PDF, OUTPUT_FORMAT.XLS];
```

### border

Sets or gets the border type, width and color.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) border type, width and color

**Sample**

```js
myElement.border='LineBorder,4,#000000';
```

### displayMode

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the display mode of the viewer

**Sample**

```js
myElement.displayMode = JR_SVY_VIEWER_DISPLAY_MODE.FIT_WIDTH;
myElement.showReport(myDataSource,"myReport.jrxml",null);
```

### font

Sets or gets the font type of the Bean's viewer.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the font type used in the viewer

**Sample**

```js
myElement.font='Tahoma,0,14';
```

### foreground

Sets or gets the foreground color.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the foreground color

**Sample**

```js
myElement.foreground='#000000';
```

### name

Gets or sets the name of the Bean.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the name of the Bean

**Sample**

```js
var beanName = myElement.name;
```

### relativeExtraDirectories

Get or set the relative path or comma separated paths to the extra resource directories of the Servoy JasperReports plugin.\
The paths are set per client and are relative to the server corresponding directories setting.

Please refer to the same property of the Servoy JasperReports plugin for more details.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the relative path or paths to the client set extra directory/directories

**Sample**

```js
myElement.extraDirectories='relative/path/to/client/extraDirectory1';
```

### relativeReportsDirectory

Property for retrieving and setting the path to the reports directory, set by the current client, relative to the server reports directory\
of the Servoy JasperReports plugin.

Please refer to the same property of the Servoy JasperReports plugin for more details.

**Type**\
[String](/reference/servoycore/dev-api/js-lib/string.md) the location of the client set reports directory, relative to the server set path

**Sample**

```js
myElement.relativeReportsDirectory = 'relativePath/to/serverReportsDirectory';
```

### transparent

**Type**\
[Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)

## Methods Detailed

### getHeight()

Gets the height of the Bean.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the height of the Bean

**Sample**

```js
var h = myElement.getHeight();
```

### getLocationX()

Gets the x-coordinate of the Bean's top-left corner location.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the x-coordinate of the Bean's top-left corner location

**Sample**

```js
var x = myElement.getLocationX();
```

### getLocationY()

Gets the y-coordinate of the Bean's top-left corner location.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the y-coordinate of the Bean's top-left corner location

**Sample**

```js
var y = myElement.getLocationY();
```

### getWidth()

Gets the width of the Bean.

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md) the width of the Bean

**Sample**

```js
var w = myElement.getWidth();
```

### setLocation(x, y)

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **x** ;
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **y** ;

**Returns:** void

### setSize(width, height)

Sets the size of the Bean.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **width** the width of the bean
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **height** the height of the bean

**Returns:** void

**Sample**

```js
myElement.setSize(800,600);
```

### showReport(source, report, parameters)

Shows the indicated report in a JasperReports Viewer (in the Bean).

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **source** the datasource (the server name, foundset or dataset) to run the report on
* [String](/reference/servoycore/dev-api/js-lib/string.md) **report** the report file to export and preview (relative to the reports directory)
* [Object](/reference/servoycore/dev-api/js-lib/object.md) **parameters** the map of parameters to be used when previewing the report

**Returns:** void

**Sample**

```js
var params = new Object();
params.SUBREPORT_DIR = "./Subreport_Tests/";
var report = myElement.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);
```

### showReport(source, report, parameters, localeString)

Shows the indicated report in a JasperReports Viewer (in the Bean).

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **source** the datasource (the server name, foundset or dataset) to run the report on
* [String](/reference/servoycore/dev-api/js-lib/string.md) **report** the report file to export and preview (relative to the reports directory)
* [Object](/reference/servoycore/dev-api/js-lib/object.md) **parameters** the map of parameters to be used when previewing the report
* [String](/reference/servoycore/dev-api/js-lib/string.md) **localeString** the string which specifies the locale

**Returns:** void

**Sample**

```js
var params = new Object();
params.SUBREPORT_DIR = "./Subreport_Tests/";
var report = myElement.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);
```

### showReport(source, report, parameters, localeString, moveTableOfContent)

Shows the indicated report in a JasperReports Viewer (in the Bean).

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **source** the datasource (the server name, foundset or dataset) to run the report on
* [String](/reference/servoycore/dev-api/js-lib/string.md) **report** the report file to export and preview (relative to the reports directory)
* [Object](/reference/servoycore/dev-api/js-lib/object.md) **parameters** the map of parameters to be used when previewing the report
* [String](/reference/servoycore/dev-api/js-lib/string.md) **localeString** the string which specifies the locale
* [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) **moveTableOfContent** true in order to move the table of contents, false otherwise

**Returns:** void

**Sample**

```js
var params = new Object();
params.SUBREPORT_DIR = "./Subreport_Tests/";
var report = myElement.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.servoy.com/guides/develop/programming-guide/jasperreports/jasperreportsservoyviewer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
