Convert .jrxml file to .pdf file

I checked a few load tests in my web application. The problem is that the load test application results are in .jrxml format. The result contains graphs of graphs and some parameters. I know its jasperreport format. Therefore, if I convert the .jrxml file to a .pdf file, I can see all the charts, graphs, and values ​​...

I assume that regardless of the contents of the .jrxml about the chart or the chart, the generated pdf will contain the corresponding values, since the template is prepared in accordance with the API.

Can I create a jasper report without specifying any connection to the data source. I do not need to connect to the data source, since the .jrxml file does not contain the datasource attribute ... If so, how can I get it. Request to offer

+4
source share
4 answers

If you don’t have a data source, you can try this

jasperReport = JasperCompileManager.compileReport(sourceFileName); jasperPrint = JasperFillManager.fillReport(jasperReport,jasperParameter,new JREmptyDataSource()); JasperExportManager.exportReportToPdfFile(jasperPrint, "D://Test.pdf"); 

Even if you do not have a data source and its static data report JREmptyDataSource .

Check the answer for more information.

Blank PDF even with the simplest Jasperreport jrxml

+6
source

.jrxml displays the jasper constructor. When you compile it, you get your parsed .jasper form. After that, you fill this object with data, parameters, variables and get a .print object. And finally, you can export this print object to any format supported by the jasper report, such as PDF, CVS, HTML, Excel ...

0
source

If by “connecting to a data source” you mean a backup JDBC data source, yes, you can run the report without requiring it.

There are other data source implementations that implement net.sf.jasperreports.engine.JRDataSource (such as JRCsvDataSource ) that are "lighter" than the database hits - useful for testing.

However, for unit tests, I create a mock implementation of JRDataSource that implements next () and getFieldValue () and reads from Collection of Map objects (it can read from a file instead, etc.). It was the easiest and fastest approach when it came to testing for me.

What part do you accurately load testing on? Usually interesting parts for a stress test are:

  • Filling out a Jasper report (running a query, reading results, and populating a JasperPrint object)

  • Jasper export (creating a report output format - HTML, PDF, XLS, etc.)

0
source

If you are not using any data source, you need to select "Empty datasource" or "Sample datasource" from the data sources, if you use sample reports, but, as I think, if you are creating a specific report for your project, then u should select a data source.

0
source

Source: https://habr.com/ru/post/1400573/


All Articles