B4J Library jJasperReports Library

Hi. I want to share this jJasperReports library with the community.
It needs several libraries to work. I provided a link: download
---More libraries needed (missing from the first link): download
You also need to download databases jdbc drivers: sql jdts, mysql and oracle
New Link (All jar files are included in this link): Download
All jars need to be placed in Additional Libraries folder.
In the B4J project you need to add a jar file: #AdditionalJar: itext-2.1.7.js1
Library files and a small example is provided.
Please feel free to test the library.
Note: for some reason when using SubReports, the compiled (.jasper) files need to be in the same level as the app jar file. XML Reports (.jrxml) can be in any other folder different from the app jar file. (e.g. if report.jrxml is in File.DirApp & "/reports" then all compiled (.jasper) subreports need to be in File.DirApp. In the example provided .jrxml and .jasper are in the same level as jaspertest.jar.

v1.00 - Release
v1.10 - SQLite support added. MySQL useSSL variable added.
v1.12 - Changed the way the JasperViewer works. Now you can set the form to full screen, use the default size and location or set a specific size and location.
v1.13 - Added method PrintDirectlyToPrinter.
v1.20 - Access support added via uCanAccess jdbc driver. Note: When creating reports in Jaspersoft Studio you need to add all jar files that ucanaccess needs. The metadata won't work but you can create a query and it will work.
v1.22 - Added functions to export report to XLS and XLSX. Note: need 2 more jar files: download. Copy them into Additional Libraries folder.
v1.24 - Added function Print3 to be able to show reports without a Data Source.

------------------------------------------

NEW VERSION 2.00
Special thanks to Num3 for testing this library and helping me getting it done.

Instructions:
1. Libraries needed: Donwload
2. Place all jars in Additional Libraries folder
3. Specify in B4J project with #AdditionalJar: the database that is going to be used. (e.g. #AdditionalJar: mysql-connector-java-5.1.49-bin)
a. If using ucanaccess-5.1.0 database please add these in addition to #AdditionalJar: ucanaccess-5.0.1:
- #AdditionalJar: commons-lang3-3.8.1
- #AdditionalJar: commons-logging-1.2
- #AdditionalJar: hsqldb-2.5.0
- #AdditionalJar: jackcess-3.0.1

v2.00 - Same functionality as v1.24 but based on jasperreports-6.17.0. Previous v1.24 was based on jasperreports-6.7.1.
 

Attachments

  • mainform.png
    mainform.png
    8.1 KB · Views: 1,777
  • jrxml_exported_to_pdf.png
    jrxml_exported_to_pdf.png
    53.9 KB · Views: 1,751
  • jrxml_subreports.png
    jrxml_subreports.png
    53.6 KB · Views: 1,829
  • jrxml_single_report.png
    jrxml_single_report.png
    16.7 KB · Views: 1,779
  • jJasperReports.zip
    10.2 KB · Views: 1,065
  • sqlite_report.png
    sqlite_report.png
    35.1 KB · Views: 1,594
  • jaspertest.zip
    2.8 KB · Views: 1,086
  • jJasperReports - 1.24.zip
    17.4 KB · Views: 767
  • jJasperReports - 2.00.zip
    17.6 KB · Views: 615
Last edited:

Roberto P.

Well-Known Member
Licensed User
Longtime User
can you post some images?
thank you
 

giannimaione

Well-Known Member
Licensed User
Longtime User
wow,
it works very well!

my report use MySql,
what does it mean, in log ?
B4X:
Sun Sep 23 20:09:17 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

set 23, 2018 8:09:19 PM net.sf.jasperreports.engine.export.PdfGlyphRenderer determinePatchedItext

AVVERTENZA: Unpatched iText found, cannot use glyph rendering
 

afields

Member
Licensed User
hello. sorry by the new library that was added is an update of one that's already here?. because i cannot locate that new library.
Thank you but anyway it's a very nice library
 

Juan Marrero

Active Member
Licensed User
Longtime User
wow,
it works very well!

my report use MySql,
what does it mean, in log ?
B4X:
Sun Sep 23 20:09:17 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

set 23, 2018 8:09:19 PM net.sf.jasperreports.engine.export.PdfGlyphRenderer determinePatchedItext

AVVERTENZA: Unpatched iText found, cannot use glyph rendering

Forgot about that. I'll add a variable to set useSSL true or false. If MySQL is configured with SSL and you try to connect without specifying useSSL=false MySQL doesn't let you connect (most of the time).
The Unpatched iText Warning is because JasperReports use a modified iText library.
 

Juan Marrero

Active Member
Licensed User
Longtime User
hello. sorry by the new library that was added is an update of one that's already here?. because i cannot locate that new library.
Thank you but anyway it's a very nice library
I replaced the original upload with the new one. The initial library was deleted. Next time I'll leave the old library and add the new one as a different upload.
 

afields

Member
Licensed User
hello to all!
Very cool that library. i've tried with sqlite (it's the one that i have more records) and also few reports designed with jasper. Each of those reports also have parameters. using jasper.parameters it's working very well.
 

Juan Marrero

Active Member
Licensed User
Longtime User
@giannimaione I added a new version of the library where you can set useSSL to false when connecting to MySQL. I also checked the JasperDesign and JasperDesignQuery functions and made them work (I used an example from internet which causes errors compiling the report but now works). Using JasperDesign and JasperDesignQuery you can change the report's query design at runtime.
 

Juan Marrero

Active Member
Licensed User
Longtime User
hello to all!
Very cool that library. i've tried with sqlite (it's the one that i have more records) and also few reports designed with jasper. Each of those reports also have parameters. using jasper.parameters it's working very well.
Glad to hear that! :D
 

Juan Marrero

Active Member
Licensed User
Longtime User
v.13 - Added a way to print directly to selected printer.

B4X:
Dim jasper As JasperReports
   Dim report As JasperReport
   Dim print As JasperPrint
   Dim conn As JasperConnection
   Dim design As JasperDesign
   Dim query As JasperDesignQuery
   
   Dim printers As List = Printer_Static.GetAllPrinters
   Dim printersList As List
   
   printersList.Initialize
   
   For Each prt As Printer In printers
       printersList.Add(prt.GetName)   
   Next
   
   Dim selPrinter As String
   
   Dim sel As Int = fx.InputList(MainForm, printersList, "Select Printer:", "Printer", -1)
   
   If sel <> fx.DialogResponse.CANCEL Then
       selPrinter = printersList.Get(sel)
   End If
   
   jasper.InitializeParameters
   jasper.InitializeJasperDesign
   jasper.GetResourceAsStream(File.Combine(File.DirApp, "mysql_example.jrxml"))
   jasper.LoadJRXml(jasper.in)
   jasper.InitializeJRDesignQuery
   jasper.SetText("select reference, code, name, pricesell from products where name like '%SQL' order by name asc")
   query = jasper.query
   jasper.SetJRDesingQuery(query)
   design = jasper.design
   report = jasper.CompileXML2(design)
   conn = jasper.getConnectionMySQL("localhost", "3306", "databasename", "user", "password", False) 'useSSL = true or false
   print = jasper.Print(report, jasper.parameters, conn)
   
   If selPrinter <> "" Then
       jasper.PrintDirectlyToPrinter(print, selPrinter, jasper.msn_NA_LETTER)
   Else
       jasper.JasperViewer(print, True)
   End If

I used jFX8Print library to select the printer name.
 
Hello Please Help Me In This Issue Am Using An Arabic Text In My Report When I Export The pdf File From I report It Showing It Correctly But When I Add The Report To The Project And Run It I Got This Error

B4X:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "DejaVu Sans Mono" is not available to the JVM. See the Javadoc for more details.
 

Juan Marrero

Active Member
Licensed User
Longtime User
Hello Please Help Me In This Issue Am Using An Arabic Text In My Report When I Export The pdf File From I report It Showing It Correctly But When I Add The Report To The Project And Run It I Got This Error

B4X:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "DejaVu Sans Mono" is not available to the JVM. See the Javadoc for more details.
Sorry for late response, my 1 year old daughter consumes most of my time. If I got this correctly, if you prepare the report and do a preview the report shows OK, but when you tried it from B4J Project it gives an error. Am I correct?
 

Juan Marrero

Active Member
Licensed User
Longtime User
Hello Please Help Me In This Issue Am Using An Arabic Text In My Report When I Export The pdf File From I report It Showing It Correctly But When I Add The Report To The Project And Run It I Got This Error

B4X:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "DejaVu Sans Mono" is not available to the JVM. See the Javadoc for more details.
I sent you a private message with a new library for you to test.
 
Top