Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/source-c/clj-jasper

A Clojure bindings to Jasper Reports
https://github.com/source-c/clj-jasper

automation clj clojure-library dkdhub jasper jasper-reports jasperreports jaspersoft pdf-generation tbt-cloud tiny

Last synced: about 1 month ago
JSON representation

A Clojure bindings to Jasper Reports

Awesome Lists containing this project

README

        

= clj-jasper

A Clojure library to work with Jasper Reports (https://clojars.org/net.tbt-post/clj-jasper[Clojars Project])

image:https://img.shields.io/github/license/source-c/clj-jasper[GitHub]
image:https://img.shields.io/clojars/v/net.tbt-post/clj-jasper.svg[]
image:https://img.shields.io/clojars/dt/net.tbt-post/clj-jasper[ClojarsDownloads]
image:https://img.shields.io/github/v/release/source-c/clj-jasper[GitHub release (latest by date)]
image:https://img.shields.io/github/release-date/source-c/clj-jasper[GitHub Release Date]
image:https://img.shields.io/github/v/tag/source-c/clj-jasper[GitHub tag (latest by date)]
image:https://img.shields.io/github/last-commit/source-c/clj-jasper[GitHub last commit]

== Usage

Add the following to your http://github.com/technomancy/leiningen[Leiningen's] `project.clj`:

.project.clj
[source,clojure]
----
[net.tbt-post/clj-jasper "0.1.0"]
----

.example.clj
[source, clojure]
----
(ns my-app.jasper
(:require [clj-jasper.core :as jc]
[clojure.java.io :as io]))

(defn render [name data properties]
(binding [jc/*jr-templates-path* "my-templates"]
(let [out (jc/data->report {:name (format "my-reports/%s" name)
:data data
:ops properties})]
{:status 200
:headers {"Content-Type" (:type out)
"Content-Disposition" (format "attachment; filename=\"%s\"" (:name out))
"Cache-Control" "no-cache"}
:body (-> out :file io/input-stream)})))
----

== Notes and limitations

. Current implementation supports only PDF generations.
. There is a bug in JAXP/XERCES (derived from CLJ<-JR<-Digester) that prevent the use of a parser that contains a schema with a DTD.
. Well tested with Java versions:
.. OpenJDK 11.0.12
.. OpenJDK 15.0.1
.. GraalVM 19.3.6.r11
.. Corretto 8.322.06.1
. Version v0.0.9 and v0.0.10 may be runtime incompatible with uberjar build in some circumstances
. JasperReports is very dependent on the SAX parser and requires at least a basic X setup on the server in order to render.
. Default font have to be available in JVM
. Final app is very sensitive to AOT compilation so pay attention on:
.. Proper AOT compilation may require added line like `:uberjar-merge-with {#"^jasperreports_extension\.properties$" [slurp #(clojure.string/join "\r\n" %&) spit]}` into your project directly.
.. For some circumstances this may be not enough, and complete avoiding of AOT for particular class might be required.
.. For some rare and very complex cases even complete avoiding `:uberjar {:aot :all}` might be highly recommended
. In order to get properly rendered reports see: http://jasperreports.sourceforge.net/sample.reference/fonts/[Jasper Reports Fonts Sample] and use a right fonts in your *.jrxml files

== License

Copyright © 2018-2022 MelKori, onoha, UPD Consulting

Distributed under the MIT License.