I am developing a plugin for QGIS which one of its functionalities is to create different reports in .pdf taking the data from a PostGIS database.
The software I am using to create the reports is: iReport 5.6.0.
The package used to generate the reports is JasperReports 6.3.1 library through JasperStarter v3.1 command-line tool.
The problem comes when I try to use the library pyreportjasper from my plugin code like this:
input_file = 'report.jasper'
output = os.path.dirname(os.path.abspath(__file__)) + '\output'
jasperpy = pyjasper.jasperpy
jasper = jasperpy.JasperPy()
input_file, output, format_list=["pdf", "rtf"])
The error I get:
File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\pyjasper\jasperpy.py", line 144, in process return self.execute() File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\pyjasper\jasperpy.py", line 183, in execute output = subprocess.check_call(self.command, shell=True) File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\subprocess.py", line 542, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command 'jasperstarter --locale pt_BR process "[INPUT_PATH]\report.jasper" -o "[OUTPUT_ROUTE]\output" -f pdf rtf' returned non-zero exit status 1
it seems that this library uses subprocess.run() and this function is implemented in Python 3.5. As far as I know, QGIS uses Python 2.7.
I’ve tried to use the console with:
jasperstarter --locale pt_BR process "[INPUT_PATH]\report.jasper" -o "[OUTPUT_PATH]\output" -f pdf rtf and it generates the report successfully
Does any one know how to deal with this issue?
If not, does anyone know another software alternative to create reports from a QGIS plugin?