Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/technologiestiftung/mapfish-print

Technologiestiftung Berlin's own mapfish instance
https://github.com/technologiestiftung/mapfish-print

mapping odis open-data

Last synced: about 2 months ago
JSON representation

Technologiestiftung Berlin's own mapfish instance

Awesome Lists containing this project

README

        

![](https://img.shields.io/badge/Built%20with%20%E2%9D%A4%EF%B8%8F-at%20Technologiestiftung%20Berlin-blue)

# mapfish-print-tsb

This setup uses the latest mapfish print service (at time of writing version 3): https://mapfish.github.io/mapfish-print-doc/

## Docker

The docker setup is build on top of the `camptocamp/mapfish_print` image. Only the print apps from this repository are added to the container. The path `${CATALINA_HOME}/webapps/ROOT/print-apps` is the path inside the container, where apps are being stored.

## Configuration

Mapfish print is an extremely powerful and highly configurable service. BUT, in most instances you will only require a tiny subset of those configs. This exemplary setup reflects this.

Mapfish print consists of so called print _apps_, this docker includes a folder called apps. Every subfolder in apps is one such print application with the name of the folder coresponding to the url it can be accessed from. Each print app must include the following components (A lot of examples for setup can be found here: https://github.com/mapfish/mapfish-print/tree/master/examples/src/test/resources/examples).

### config.yaml

This is (obviously) the main config file. The values under attributes are most likely the most important bits especially when you start. Be adviced, when you are sending additional attributes to the endpoint, which are not documented in config.yaml printing will fail. To solve this simply add the additional attributes here and in report.jrxml and then simply ignore them. For complex examples for config.yaml, see link above).

### requestData.json

This documents a sample json-request to the endpoint.

### report.jrxml

This is the print layout of the report. The file can be build through Jaspersoft Studio (free after registration, https://community.jaspersoft.com/project/jaspersoft-studio) or (recommended) build it in a code editor. Completely building it in Jaspersoft Studio is a good way to start, but I personally still had to finetune the code later. So in the end i build the whole thing in code. If you look at the provided example it looks a bit overwhelming in the begining, but it is actually quite straight forward. A few points of advice:

#### Request Parameters

```xml

```

In some examples you will also find the `` parameter, i have not yet understood the difference, but if you use _field_ make sure that when you reference the variable later on use `$F{title}` instead of `$P{title}`.
Furthermore, request parameters are always of type `java.lang.String` even if they are not (at least in my case).

#### Adding elements by hand

Don't forget to add valid `uuid`s to each element, otherwise you will receive errors.

#### Adding/Combining Parameters

```xml

```

#### Using Java Functions

```xml

```

#### Local Images

Japsersoft Studio provides various ways of referencing images, but not a local/relative path to an image. Don't worry, simply do it later in the code editor. It works fine:

```xml

```

#### Top-level groups

When organising your report, you can add top-level groups under which you organize your elements. They follow specific rules. I used:

- title
- detail
- pageFooter
see also: http://www.alexander-merz.com/42.html (in German)

## Running

```bash
docker run -pYOURPORT:8080 -e TOMCAT_LOG_TYPE='json' YOURDOCKERNAME
```

## Security

Before public distribution the allowedReferers should be set, to stop unwanted requests:

```yaml
allowedReferers:
- !hostnameMatch
host: example.com
allowSubDomains: true
```

see also: https://mapfish.github.io/mapfish-print-doc/configuration.html

## Running on render.com

This app is a bit more resource intensive and requires at least 1Gig of ram. The amount of ram also depends on the DPI and size of the reports. Bigger reports, higher resolution will require more ram.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Sebastian Meier

πŸ’» πŸ“–

Fabian MorΓ³n Zirfas

πŸ’» πŸ“–

Lucas Vogel

πŸ“–

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## Credits












A project by:








Supported by: