{ "info": { "author": "Jadson Bonfim Ribeiro", "author_email": "contato@jadsonbr.com.br", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Reports for Python, with JasperReports.\n=======================================\n\n|Build Status| |Coverage Status| |PyPI|\n\n**Is using Linux servers?**\n\nDo not forget to grant permission 777 for the directory where is the\npackage.\n\nIntroduction\n------------\n\nThis package aims to be a solution to compile and process JasperReports\n(.jrxml & .jasper files).\n\nWhy?\n~~~~\n\nDid you ever had to create a good looking Invoice with a lot of fields\nfor your great web app or desktop?\n\nI had to, and the solutions out there were not perfect. Generating\n*HTML* + *CSS* to make a *PDF*? WTF? That doesn't make any sense! :)\n\nThen I found **JasperReports** the best open source solution for\nreporting.\n\nWhat can I do with this?\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nWell, everything. JasperReports is a powerful tool for **reporting** and\n**BI**.\n\n**From their website:**\n\n The JasperReports Library is the world's most popular open source\n reporting engine. It is entirely written in Java and it is able to\n use data coming from any kind of data source and produce\n pixel-perfect documents that can be viewed, printed or exported in a\n variety of document formats including HTML, PDF, Excel, OpenOffice\n and Word.\n\nIt is recommended using `Jaspersoft\nStudio `__ to\nbuild your reports, connect it to your datasource (ex:JSON, XML, MySQL,\nPOSTGRES, SQL Server), loop thru the results and output it to PDF, XLS,\nDOC, RTF, ODF, etc.\n\n*Some examples of what you can do:*\n\n- Invoices\n- Reports\n- Listings\n\nPackage to generate reports with\n`JasperReports `__\nlibrary through\n`JasperStarter `__\ncommand-line tool.\n\nRequirements\n------------\n\n- Java JDK 1.8\n- Python\n `subprocess.run() `__\n function\n\nOptional\n--------\n\n- `Mysql JDBC `__ (if you\n want to use database)\n- `PostgreSQL JDBC `__ (if\n you want to use database)\n- `SQL Server\n JDBC `__\n (if you want to use database)\n- `Oracle\n JDBC `__\n (if you want to use database)\n- `MongoDB JDBC `__ (if\n you want to use database)\n- `Jaspersoft\n Studio `__\n (to draw and compile your reports)\n\nNote\n~~~~\n\n- The JDBC driver of your database should be place in the\n ``pyreportjasper/jasperstarter/jdbc/`` directory.\n- Using **pyreportjasper**, you can also access different types of data\n sources, including CSV, JDBC, JSON, NoSQL, XML, or your own custom\n data source.\n\nJava (JDK and JRE)\n~~~~~~~~~~~~~~~~~~\n\nCheck if you already have Java installed:\n\n::\n\n $ javac -version\n javac version 1.8.0_101\n\nIf you get:\n\n::\n\n command not found: javac\n\nThen install it with: (Ubuntu/Debian)\n\n::\n\n $ sudo apt-get install default-jdk\n\nTo install on: (centOS/Fedora)\n\n::\n\n # yum install java-1.8.0-openjdk.x86_64\n\nTo install on windows visit the link->\n`JDK `__\nand look for the most appropriate version for your system.\n\nNow run the ``javac -version`` again and check if the output is ok.\n\nInstallation\n------------\n\nInstall `PyPI `__ if you\ndon't have it.\n\n::\n\n pip install pyreportjasper\n\nUsing the code\n~~~~~~~~~~~~~~~\n\nPyreport is actively developed in GitHub, where code is `always\navailable `__.\n\nYou can clone the public repository:\n\n::\n\n git clone git://github.com/jadsonbr/pyreportjasper.git\n\nDownload `tar\nfile `__:\n\n::\n\n curl -OL https://github.com/jadsonbr/pyreportjasper/tarball/master\n\nOr, Download the `zip\nfile `__:\n\n::\n\n curl -OL https://github.com/jadsonbr/pyreportjasper/zipball/master\n\nUnzip the downloaded file\n\nNavigate to the unzipped folder\n\nOnce you have a copy of the code, you can easily include it in your\nPytohn package, or install it in your site-packages directory:\n\n::\n\n $ python setup.py install\n\nExamples\n--------\n\nThe *Hello World* example.\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nGo to the examples directory in the root of the package Open the\n``test/examples/hello_world.jrxml`` file with Jaspersoft Studio or with\nyour favorite text editor and take a look at the source code.\n\nCompiling\n^^^^^^^^^\n\nFirst we need to compile our ``JRXML`` file into a ``JASPER`` binary\nfile. We just have to do this one time.\n\n**Note 1:** You don't need to do this step if you are using *Jaspersoft\nStudio*. You can compile directly within the program.\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n\n def compiling():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/hello_world.jrxml'\n jasper = JasperPy()\n jasper.compile(input_file)\n\nThis commando will compile the ``hello_world.jrxml`` source file to a\n``hello_world.jasper`` file.\n\nProcessing\n^^^^^^^^^^\n\nNow lets process the report that we compile before:\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n\n def processing():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/hello_world.jrxml'\n output = os.path.dirname(os.path.abspath(__file__)) + '/output/examples'\n jasper = JasperPy()\n jasper.process(\n input_file, output_file=output, format_list=[\"pdf\", \"rtf\"])\n\nNow check the examples folder! :) Great right? You now have 2 files,\n``hello_world.pdf`` and ``hello_world.rtf``.\n\nCheck the *API* of the ``compile`` and ``process`` functions in the file\n``pyreportjasper/jasperpy.py`` file.\n\nListing Parameters\n^^^^^^^^^^^^^^^^^^\n\nQuerying the jasper file to examine parameters available in the given\njasper report file:\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n\n def listing_parameters():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/hello_world_params.jrxml'\n jasper = JasperPy()\n output = jasper.list_parameters(input_file)\n print(output)\n\nAdvanced example - using a database\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe can also specify parameters for connecting to database:\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from platform import python_version\n from pyreportjasper import JasperPy\n\n def advanced_example_using_database():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/hello_world.jrxml'\n output = os.path.dirname(os.path.abspath(__file__)) + '/output/examples'\n con = {\n 'driver': 'postgres',\n 'username': 'DB_USERNAME',\n 'password': 'DB_PASSWORD',\n 'host': 'DB_HOST',\n 'database': 'DB_DATABASE',\n 'schema': 'DB_SCHEMA',\n 'port': '5432'\n }\n jasper = JasperPy()\n jasper.process(\n input_file,\n output_file=output,\n format_list=[\"pdf\", \"rtf\", \"xml\"],\n parameters={'python_version': python_version()},\n db_connection=con,\n locale='pt_BR' # LOCALE Ex.:(en_US, de_GE)\n )\n\n**Note 2:**\n\nFor a complete list of locales see `Supported\nLocales `__\n\nReports from a XML\n~~~~~~~~~~~~~~~~~~\n\nSee how easy it is to generate a report with a source an XML file:\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n\n def xml_to_pdf():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/CancelAck.jrxml'\n\n output = os.path.dirname(os.path.abspath(__file__)) + '/output/_CancelAck'\n\n data_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/CancelAck.xml'\n\n jasper = JasperPy()\n\n jasper.process(\n input_file,\n output_file=output,\n format_list=[\"pdf\"],\n parameters={},\n db_connection={\n 'data_file': data_file,\n 'driver': 'xml',\n 'xml_xpath': '/CancelResponse/CancelResult/ID',\n },\n locale='pt_BR' # LOCALE Ex.:(en_US, de_GE)\n )\n\n print('Result is the file below.')\n print(output + '.pdf')\n \n\nReports from a JSON File\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nSee how easy it is to generate a report with a source an JSON file:\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n\n def json_to_pdf():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/json.jrxml'\n\n output = os.path.dirname(os.path.abspath(__file__)) + '/output/_Contacts'\n json_query = 'contacts.person'\n\n data_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/contacts.json'\n\n jasper = JasperPy()\n jasper.process(\n input_file,\n output_file=output,\n format_list=[\"pdf\"],\n parameters={},\n db_connection={\n 'data_file': data_file,\n 'driver': 'json',\n 'json_query': json_query,\n },\n locale='pt_BR' # LOCALE Ex.:(en_US, de_GE)\n )\n\n print('Result is the file below.')\n print(output + '.pdf')\n\n**Note 3:**\n\nJasperReports can process JSON files using either the `original JSON DataSource\n`__\nor the `newer JSONQL Data Source\n`__.\nRefer to the JSONQL DataSource documentation for the differences. The example above\nuses the JSON DataSource. To use the enhanced capabilities of the JSONQL DataSource\ninstead use:\n\n- the ``jsonql.jrxml`` input file\n- the ``jsonql`` driver setting\n- the ``jsonql_query`` query setting\n\nby changing these three parts of the example:\n\n.. code-block:: python\n\n ...\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/jsonql.jrxml'\n ...\n db_connection={\n ...\n 'driver': 'jsonql',\n 'jsonql_query': json_query,\n },\n\n\nSubreport Example\n~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n\n def subreport_example():\n\n input_file_header = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/subreports/header.jrxml'\n\n input_file_details = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/subreports/details.jrxml'\n\n input_file_main = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/subreports/main.jrxml'\n\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/subreports/main.jasper'\n\n data_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/subreports/contacts.xml'\n\n output = os.path.dirname(os.path.abspath(__file__)) + '/output/examples/subreports/'\n\n jasper = JasperPy()\n\n jasper.compile(input_file_header)\n jasper.compile(input_file_details)\n jasper.compile(input_file_main)\n\n jasper.process(\n input_file,\n output_file=output,\n format_list=[\"pdf\"],\n parameters={},\n db_connection={\n 'data_file': data_file,\n 'driver': 'xml',\n 'xml_xpath': '\"/\"',\n },\n locale='pt_BR', # LOCALE Ex.:(en_US, de_GE)\n resource='examples/subreports/'\n )\n\nFlask Example\n~~~~~~~~~~~~~\n\nGet parameters via URL and filter them if they are valid parameters for\nthe *jrxml* file:\n\nAfter runnig you could visit\nhttp://localhost:5000/?myString=My%20Beautiful%20String&myInt=1&myDate=2017-01-01&this\\_parameter=ignored\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from pyreportjasper import JasperPy\n from flask import Flask, request, make_response\n\n\n app = Flask(__name__)\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/hello_world_params.jrxml'\n jasper = JasperPy()\n\n\n def compiling():\n jasper.compile(input_file)\n\n def processing(parameters):\n output_file = os.path.dirname(os.path.abspath(__file__)) + '/output/examples'\n jasper.process(\n input_file, output_file, parameters=parameters, format_list=[\"pdf\"])\n\n def filter_parameters(request_args):\n list_parameters = jasper.list_parameters(input_file)\n parameters = {}\n for key in list_parameters:\n if key in request_args:\n parameters[key] = request_args[key]\n return parameters\n\n @app.route('/')\n def my_route():\n request_args = request.args.to_dict()\n parameters = filter_parameters(request_args)\n\n processing(parameters)\n\n try:\n with app.open_resource(os.path.dirname(os.path.abspath(__file__)) + '/output/examples/hello_world_params.pdf') as f:\n content = f.read()\n resposta = make_response(content)\n resposta.headers['Content-Type'] = 'application/pdf; charset=utf-8'\n resposta.headers['Content-Disposition'] = 'inline; filename=hello_world_params.pdf'\n return resposta\n except IOError:\n return make_response(\"

403 Forbidden

\", 403)\n\n if __name__ == '__main__':\n compiling()\n app.run(host='0.0.0.0')\n\nWorking with resources (i18n resource bundles, icons or images)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you need provide resource to report, you can do that by set parameter\n``resource`` in method ``jasper.process``. More details `jasper starter\nmanual\npage `__.\n\n.. code-block:: python\n\n # -*- coding: utf-8 -*-\n import os\n from platform import python_version\n from pyreportjasper import JasperPy\n\n def advanced_example_using_database():\n input_file = os.path.dirname(os.path.abspath(__file__)) + \\\n '/examples/hello_world.jrxml'\n output = os.path.dirname(os.path.abspath(__file__)) + '/output/examples'\n con = {\n 'driver': 'postgres',\n 'username': 'DB_USERNAME',\n 'password': 'DB_PASSWORD',\n 'host': 'DB_HOST',\n 'database': 'DB_DATABASE',\n 'schema': 'DB_SCHEMA',\n 'port': '5432'\n }\n jasper = JasperPy()\n jasper.process(\n input_file,\n output_file=output,\n format_list=[\"pdf\", \"rtf\", \"xml\"],\n parameters={'python_version': python_version()},\n db_connection=con,\n locale='pt_BR', # LOCALE Ex.:(en_US, de_GE)\n resource='path/to/my/resource/myresource.jar'\n )\n\nTests\n~~~~~\n\nAll tests are in in the ``test`` directory. To run them\n\n::\n\n python setup.py test\n\nPerformance\n-----------\n\nDepends on the complexity, amount of data and the resources of your\nmachine (let me know your use case).\n\nI have a report that generates a *Invoice* with a DB connection, images\nand multiple pages and it takes about **3/4 seconds** to process. I\nsuggest that you use a worker to generate the reports in the background.\n\nQuestions?\n----------\n\nOpen a `Issue `__\n\nContribute\n----------\n\nContribute to the community Python, feel free to contribute, make a\nfork!!\n\nContributors\n~~~~~~~~~~~~\n\n- `List of\n contributors `__\n\nThanks\n------\n\nThanks to `Cenote GmbH `__ for the\n`JasperStarter `__ tool.\n\n.. |Build Status| image:: https://travis-ci.org/PyReportJasper/pyreportjasper.svg?branch=master\n :target: https://travis-ci.org/PyReportJasper/pyreportjasper\n.. |Coverage Status| image:: https://coveralls.io/repos/github/PyReportJasper/pyreportjasper/badge.svg?branch=master\n :target: https://coveralls.io/github/PyReportJasper/pyreportjasper?branch=master\n.. |PyPI| image:: https://img.shields.io/pypi/l/pyreportjasper.svg\n :target: https://github.com/PyReportJasper/pyreportjasper/blob/master/LICENSE\n", "description_content_type": "", "docs_url": "https://pythonhosted.org/pyreportjasper/", "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PyReportJasper/pyreportjasper", "keywords": "report jasper python", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "pyreportjasper", "package_url": "https://pypi.org/project/pyreportjasper/", "platform": "any", "project_url": "https://pypi.org/project/pyreportjasper/", "project_urls": { "Homepage": "https://github.com/PyReportJasper/pyreportjasper" }, "release_url": "https://pypi.org/project/pyreportjasper/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "This package aims to be a solution to compile and process JasperReports (.jrxml & .jasper files).", "version": "1.0.2" }, "last_serial": 4482373, "releases": { "0.1.3": [ { "comment_text": "", "digests": { "md5": "419088e7fcee379e4da57b35573cfe62", "sha256": "9600ccae27d6859323a53a012e1623d9aeef3dd481e02d6849e371bb83f84517" }, "downloads": -1, "filename": "pyreportjasper-0.1.3.tar.gz", "has_sig": false, "md5_digest": "419088e7fcee379e4da57b35573cfe62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42162330, "upload_time": "2016-11-24T03:32:42", "url": "https://files.pythonhosted.org/packages/45/62/d00fa9f183fb0424ae4b46839c9564659242ad5f051bb7d36926dc10b4e1/pyreportjasper-0.1.3.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "a97a0e7bc37567f2c61205658df07fd4", "sha256": "46632e7618ab3a587da7e388148b0227533c793852fba3eb3625610e99c98b58" }, "downloads": -1, "filename": "pyreportjasper-0.1.5.tar.gz", "has_sig": false, "md5_digest": "a97a0e7bc37567f2c61205658df07fd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3513, "upload_time": "2017-04-05T20:31:33", "url": "https://files.pythonhosted.org/packages/ef/be/717309ad54702581670ba4d2668c271e3237a7aa650f120795df50519b1d/pyreportjasper-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "76185131fab17aeb91a62a5a0f39c961", "sha256": "427c26c289ba3595f0315cac9e83e920124b67d1767b2185d4e9521045a41eb6" }, "downloads": -1, "filename": "pyreportjasper-0.1.6.tar.gz", "has_sig": false, "md5_digest": "76185131fab17aeb91a62a5a0f39c961", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42774092, "upload_time": "2017-04-07T20:07:05", "url": "https://files.pythonhosted.org/packages/11/54/69f0284e429caf20811dccc9931141489dd15a04683385e5d220d8917b20/pyreportjasper-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "0c014e0cd9c7da3d1712061c0421d4b9", "sha256": "c9dc2192b25d9447856a74c9cad7f5e7afd18c453ba2570343c4f8802d260b94" }, "downloads": -1, "filename": "pyreportjasper-0.1.7.tar.gz", "has_sig": false, "md5_digest": "0c014e0cd9c7da3d1712061c0421d4b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 54407687, "upload_time": "2017-06-09T02:46:34", "url": "https://files.pythonhosted.org/packages/88/cd/f0cff257e1fa4476e9b6328d745923392f483a0a7d1e7f5446165fbdd84d/pyreportjasper-0.1.7.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "f81503f4b348c52901e4fe0be5fd7cc7", "sha256": "47c76c2618570aae4cf429bf524598490bd4e49bf77b060c5f0fcfa9d3e4b3ab" }, "downloads": -1, "filename": "pyreportjasper-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f81503f4b348c52901e4fe0be5fd7cc7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 79690911, "upload_time": "2018-05-22T16:37:41", "url": "https://files.pythonhosted.org/packages/55/5d/454639d966fb3dc65f2e6c69120d86ac02dc2b3fb8b8a4c4e09b834084ac/pyreportjasper-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "7d4d5dd9159f6d8a39a924b9068ddad2", "sha256": "8e7168e4a75518db66bc720d2359b789967eeb8e06fc7514e4825438864eb6a8" }, "downloads": -1, "filename": "pyreportjasper-1.0.2.tar.gz", "has_sig": false, "md5_digest": "7d4d5dd9159f6d8a39a924b9068ddad2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 77009096, "upload_time": "2018-11-13T16:26:11", "url": "https://files.pythonhosted.org/packages/25/64/d73f0c63c637251c4438dc68833157dcc6c31ef528fe2a6c3460da149946/pyreportjasper-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7d4d5dd9159f6d8a39a924b9068ddad2", "sha256": "8e7168e4a75518db66bc720d2359b789967eeb8e06fc7514e4825438864eb6a8" }, "downloads": -1, "filename": "pyreportjasper-1.0.2.tar.gz", "has_sig": false, "md5_digest": "7d4d5dd9159f6d8a39a924b9068ddad2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 77009096, "upload_time": "2018-11-13T16:26:11", "url": "https://files.pythonhosted.org/packages/25/64/d73f0c63c637251c4438dc68833157dcc6c31ef528fe2a6c3460da149946/pyreportjasper-1.0.2.tar.gz" } ] }