Giter Site home page Giter Site logo

gbfragoso / jasperviewerfx Goto Github PK

View Code? Open in Web Editor NEW
33.0 1.0 22.0 15.25 MB

The JasperViewerFX is a free JavaFX library which aims to avoid use of JasperReport's swing viewer

Java 100.00%
javafx-8 javafx-library jasperreports javafx pdf-viewer pdf-generation

jasperviewerfx's Introduction

JasperViewerFX

The JasperViewerFX aims to avoid usage of default Swing JasperReport's viewer. This viewer use SwingFXUtils to render only one page at time and append the output image to an ImageView.

Viewer image

Limitations

JasperReports draw engine relies on awt graphics, drawing each element on a Graphics2D canvas. The JavaFX's GraphicsContext is incompatible with Graphics2D so, even translating the drawing methods, we have memory leaks in some situations. The ImageView method has better overall performance and doesn't cause memory problems, but prevent user to click links and the zoom quality decrease when scaling images.

Features

  • Exporting for PDF, HTML, XML (Without images), XLS, XLSX;
  • Zoom in / Zoom Out;
  • Interface completely written in JavaFX;
  • Current page property.

Dependencies

<dependencies>
	<dependency>
		<groupId>net.sf.jasperreports</groupId>
		<artifactId>jasperreports</artifactId>
		<version>6.13.0</version>
	</dependency>
</dependencies>

Minimal Setup

  • Tested with: jasperreports-6.0.0.jar (or above) and Java 8

Older versions

In older versions of this project the JasperPrint's generation method has been abstracted. We decided to focus on just viewing the report and let the user decide how to generate it.

How to use

Example with JDBC connection

try {
	Connection con = new ConnectionManager().getConnection();
	JasperReport jreport = (JasperReport) JRLoader.loadObject(getClass().getResource("your_resource_path"));
	JasperPrint jprint = JasperFillManager.fillReport(jreport, null, con);
	new JasperViewerFX(primaryStage).viewReport("Simple report", jprint);
	con.close();
} catch (JRException | SQLException e) {
	e.printStackTrace();
}

Example with JRBeanCollectionDataSource

try {
	JRBeanCollectionDataSource source = new JRBeanCollectionDataSource(collection);
	JasperReport jreport = (JasperReport) JRLoader.loadObject(getClass().getResource("your_resource_path"));
	JasperPrint jprint = JasperFillManager.fillReport(jreport, null, source);
	new JasperViewerFX().viewReport("JRBeanCollectionDataSource example", jprint);
} catch (JRException e) {
	e.printStackTrace();
}

jasperviewerfx's People

Contributors

gbfragoso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jasperviewerfx's Issues

Trouble with printAction

Hi gbfragoso,

when I execute printAction occurs an error if true parameter of JasperPrintManager.printReport is set and don´t show print dialog to choice of a printer:
net.sf.jasperreports.engine.JRException: Error printing report.
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:215)

Thank you in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.