acesseonline / pyreportjasper

Python Reporting with JasperReports
https://pyreportjasper.readthedocs.io/en/latest/
GNU General Public License v3.0
126 stars 73 forks source link

Print Screen from Reports for Python, with JasperReports. #20

Closed rmatarritaq closed 6 years ago

rmatarritaq commented 6 years ago

I found this code posted by Mr Jadsonbr, adapted to my needs, and it works.

I have the following questions.

  1. Can i see the report on screen before you burn it to disk.
  2. How to send parameters to the report, for example the invoice number, company code.

Tanks Robert Costa Rica

import sys import os import pyjasper from platform import python_version from pyjasper.jasperpy import JasperPy

def advanced_example_using_database():

input_file = os.path.dirname(os.path.abspath(file)) + '/report4.jrxml' output = os.path.dirname(os.path.abspath(file)) + '/reportes' print(input_file) print(output)

con = { 'driver': 'postgres', 'username': 'postgres', 'password': 'Administra8080', 'host': 'localhost', 'database': 'municipal', 'port':'5432' } jasper = JasperPy() jasper.process(input_file,output_file=output,format_list=["pdf"],db_connection=con)

jadsonbr commented 6 years ago

For parameter you can use the parameters argument of the jasper.process method

Here you can see an example -> Link

--

You can only view the report through the library after export. So for now we only export the reports to PDF, XLS, DOC, RTF, ODF, etc. formats.

Who knows in a future version we implemented.

rmatarritaq commented 6 years ago

This is what I do not understand.

You can only view the report through the library after export. So for now we only export the reports to PDF, XLS, DOC, RTF, ODF, etc. formats.

The user needs to see the report before taking a decision. My question is, once I call the report from python, the user can see it first. Then print it, send it to a ppdf, etc.

Thank you.

2017-11-23 20:49 GMT-06:00 Jadson Ribeiro notifications@github.com:

For parameter you can use the parameters argument of the jasper.process method

Here you can see an example -> Link https://github.com/jadsonbr/pyreport#working-with-resources-i18n-resource-bundles-icons-or-images

--

You can only view the report through the library after export. So for now we only export the reports to PDF, XLS, DOC, RTF, ODF, etc. formats.

Who knows in a future version we implemented.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-346730078, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqtmChfnPwqG5zNWVBzmXDJ_Tt3cBks5s5i6zgaJpZM4QpNoU .

rmatarritaq commented 6 years ago

Jadson Ribeiro, já consegui imprimir os parâmetros de envio como indicado no exemplo. Eu quase consegui o meu objetivo em relatórios. Eu só preciso agradar, como ver o relatório na tela antes de imprimi-lo. Eu preciso escolher a impressora de saída. Preciso de ajuda sozinho sobre isso. Se você gosta, escreva-me em inglês. Obrigado Roberto

Código import sys import os import pyjasper from platform import python_version from pyjasper.jasperpy import JasperPy #def advanced_example_using_database(): input_file = os.path.dirname(os.path.abspath(file)) + '/report4.jrxml' output = os.path.dirname(os.path.abspath(file)) + '/reportes' print(input_file) print(output) con = { 'driver': 'postgres', 'username': 'postgres', 'password': 'Administra8080', 'host': 'localhost', 'database': 'municipal', 'port':'5432' } x=input("Digite codigo de empleado :") jasper = JasperPy() jasper.process(input_file,output_file=output,format_list=["pdf"], parameters={'idenifica': (x)},db_connection=con)

2017-11-23 20:49 GMT-06:00 Jadson Ribeiro notifications@github.com:

For parameter you can use the parameters argument of the jasper.process method

Here you can see an example -> Link https://github.com/jadsonbr/pyreport#working-with-resources-i18n-resource-bundles-icons-or-images

--

You can only view the report through the library after export. So for now we only export the reports to PDF, XLS, DOC, RTF, ODF, etc. formats.

Who knows in a future version we implemented.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-346730078, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqtmChfnPwqG5zNWVBzmXDJ_Tt3cBks5s5i6zgaJpZM4QpNoU .

jadsonbr commented 6 years ago

So Robert what you show to the user for the decision making whether it will print or not is the generated file in the format you specified at the time of export. Who does the management of where it will be printed is the browser itself. If you want something desktop-type you can see something like the link on the side -> Link

More will not be through this library, but with JasperReport.

rmatarritaq commented 6 years ago

If that is what I occupy. But how can I adapt it to python? How do I import that module Thank you.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

2017-11-24 5:03 GMT-06:00 Jadson Ribeiro notifications@github.com:

So Robert what you show to the user for the decision making whether it will print or not is the generated file in the format you specified at the time of export. Who does the management of where it will be printed is the browser itself. If you want something desktop-type you can see something like the link on the side -> Link https://community.jaspersoft.com/questions/541288/execute-and-preview-jasper-report-pdf-format-without-saving-pdf-file-somewhere

More will not be through this library, but with JasperReport.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-346803081, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqmpOQrk942bHeIEZ_nPBBW4rd4N9ks5s5qJ-gaJpZM4QpNoU .

jadsonbr commented 6 years ago

I did not understand Adapt what? Import what module?

rmatarritaq commented 6 years ago

I need to see the report on the screen. How do I implement this code in python?

JasperViewer.viewReport (jasperPrint);

Tanks.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

2017-11-24 12:56 GMT-06:00 Jadson Ribeiro notifications@github.com:

I did not understand

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-346883284, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqr6e3bMg2JnfwPzTD6z7vPd-g5F5ks5s5xFSgaJpZM4QpNoU .

jadsonbr commented 6 years ago

This JasperReport library along with JasperView is in Java. One way to execute java command with python is through jython . Most recommend the one researched on the internet. Remembering that what you want is not part of our library.

rmatarritaq commented 6 years ago

Jadson, I need please help me. I've done everything to see a jasper report on the screen from pythopn, but I could not get it. Only that I need. This instruction does not know how to use it.

I know there must be a form from python, to be able to see the preview, of a report with jasper.

Thank you.

2017-11-24 14:17 GMT-06:00 Jadson Ribeiro notifications@github.com:

This JasperReport library along with JasperView is in Java.

One way to execute java command with python is through jython http://www.jython.org/

Most recommend the one researched on the internet

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-346891528, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqiffMckozFSFXgrI2-OyHA4kGwj_ks5s5yRPgaJpZM4QpNoU .

jadsonbr commented 6 years ago

How we try to explain this is not a feature of our library. Our library only exports the reports to some specific formats

If you want to use our library you can export the report for example in pdf display this pdf in the browser for the user to make the decision if he wants to print or not

rmatarritaq commented 6 years ago

Español

That is what I need. See the report in the browser, but I do not know how to do it.

Thank you.

2017-11-28 5:49 GMT-06:00 Jadson Ribeiro notifications@github.com:

How we try to explain this is not a feature of our library. Our library only exports the reports to some specific formats

If you want to use our library you can export the report for example in pdf display this pdf in the browser for the user to make the decision if he wants to print or not

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-347499718, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqgo3FUcx4xuYXHSOcpY8sh349YLpks5s6_NYgaJpZM4QpNoU .

jadsonbr commented 6 years ago

you are using some framework ? Example: Flask or Django

rmatarritaq commented 6 years ago

I use, postgresql, python 3.5, pyqt5 framework. At the moment I am testing the code from sublimetext. Everything works well. This instruction works correctly. jasper = JasperPy () jasper.process (input_file, output_file = output, format_list = ["pdf"], parameters = {'idenifica': (x)}, db_connection = con)

It connects, sends the parameters and executes the report based on the parameters. The problem, like seeing the report first on the screen, before recording it or taking the decision to make a pdf, xls, etc. If you taught me to get to this point, I think it should be easy to see the report on the screen. Sorry for the inconvenience, but only you have helped me in this. Thank you. Robert.

2017-11-28 13:06 GMT-06:00 Jadson Ribeiro notifications@github.com:

you are using some framework ? Example: Flask or Django

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-347629949, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqlP0PS9XzsjM-oAo8kWQp6z5nh9qks5s7FmlgaJpZM4QpNoU .

jadsonbr commented 6 years ago

I've never worked with PyQt5 but I think it's something like that.

Link

rmatarritaq commented 6 years ago

I am trying to execute the code you sent me. But I get the following error in this line. My application is desktop and not web. web = QWebView () Unexpected error: <class 'NameError'> Thanks for the help.

2017-11-28 13:29 GMT-06:00 Jadson Ribeiro notifications@github.com:

I've never worked with PyQt5 but I think it's something like that.

Link https://dpaste.de/mYf0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-347636874, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqql8USWFIb4h8KPSUfazzZif6eQqyks5s7F8vgaJpZM4QpNoU .

jadsonbr commented 6 years ago

I can not help much because I do not know desktop development with python very well. I recommend looking for help in specialized groups

rmatarritaq commented 6 years ago

I understand. Rather, I thank you very much for all the help you have given me in this matter, for you have been a very kind person. One last query. How do I install these two instructions in Python since they give me an error, and I think it's due to lack of installation. from PyQt5.QtWidgets import from PyQt5.QtWebKit import

Thank you very much for all the help.

Robert.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

2017-11-29 7:02 GMT-06:00 Jadson Ribeiro notifications@github.com:

I can not help much because I do not know desktop development with python very well. I recommend looking for help in specialized groups

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-347853965, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqkDTS-Ocr5NVjQaSBhsSdHGTWc7dks5s7VYAgaJpZM4QpNoU .

rmatarritaq commented 6 years ago

Hello Friend. I have already seen the report on the screen, with these instructions. webbrowser.open_new (r'file: /// '+ output +' .pdf ') os.startfile (filename) os.system (filename) Thank you very much for all the help you gave me, you were a great person.

Robert Costa Rica.

2017-11-29 7:02 GMT-06:00 Jadson Ribeiro notifications@github.com:

I can not help much because I do not know desktop development with python very well. I recommend looking for help in specialized groups

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jadsonbr/pyreport/issues/20#issuecomment-347853965, or mute the thread https://github.com/notifications/unsubscribe-auth/AgXqqkDTS-Ocr5NVjQaSBhsSdHGTWc7dks5s7VYAgaJpZM4QpNoU .