I am using jasperreport api-s to generate reports for my web application and i am converting the same in HTML , PDF , EXCEL and CSV formats .
I am creating it in the following way .
JasperReport jasperReport = null;
JRDesignQuery jq = new JRDesignQuery();
jq.setText("select * from employeetab"); //SQL Query might return 10-1000 or more records
jasperDesign.setQuery(jq);
jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = null;
jasperPrint = JasperFillManager.fillReport(jasperReport, null, dbconnection);
while executing JasperFillManager.fillReport(jasperReport, null, dbconnection) , but the server is taking too much time at times , and sometimes it does not even show up .
The issue is not very consistent .
The application is deployed in a Linux Server .
I have also tested in windows but i hardly face the above issue .
Any idea what might be the issue ??
If you are exporting to HTML, jasper can be very, very slow. This is because the HTML it is outputting is super verbose - if your report has 1000 lines in it, it could be several megabytes in size.
Related
I just finished a new service for creating pdf export which contains parts with html strings (two cells in a table), so I had to use pdfHTML. My code part:
FontProvider fontProvider = new DefaultFontProvider(true, true, true);
ConverterProperties properties = new ConverterProperties();
properties.setCharset("UTF-8");
properties.setFontProvider(fontProvider);
InputStream isStav = new ByteArrayInputStream((pdfData.get().getStav() == null ? "" : pdfData.get().getStav()).getBytes());
List<IElement> elements =
HtmlConverter.convertToElements(isStav, properties);
Everything worked perfectly on my local machine, but the setCharset("UTF-8") part gets ignored, when I deploy my project to a Wildfly server (hosted on microsoft windows server 2016).
the result when I download a pdf looks like this:
"Nemali by však zásadne preká�a? v testovaní.".
How can I set the charSet correctly on the server? Is it servers fault, or should I change something in my code?
As a default font I use PdfFont, but I could't pass it to FontProvider:
PdfFont fNormal = PdfFontFactory.createFont(StandardFonts.HELVETICA, "CP1250");
Thank you.
I am trying to export excel jasper report in RTL mode.It does not appear that my report properties are working correctly.
In this report I am using the below property to direct my excel sheet ti RTL.
net.sf.jasperreports.export.xlsx.sheet.direction=RTL
I tried another way too:
exporter = new JRXlsxExporter();
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out));
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
configuration.setSheetDirection(RunDirectionEnum.RTL);
exporter.setConfiguration(configuration);
None of the above solutions are working. Please,somebody help me out.
It seems the xlxs does not support the sheet RTL, you can use xlx as below:
exporter = new JRXlsExporter();
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out));
SimpleXlsReportConfiguration xlsReportConfig = new SimpleXlsReportConfiguration();
xlsReportConfig.setSheetDirection(RunDirectionEnum.RTL);
exporter.setConfiguration(xlsReportConfig);
The issue has been raised at: http://community.jaspersoft.com/jasperreports-library/issues/6566
I am developing windows application. In that, I using crystal report v13.0.2000.0. and used ExporttoDisk Method to create PDF file from Crystal report. and we are using TSScan for scanning purpose as scanner is in remote place.
When i try to Export the file on Disk using Crystal report DLL and then after i try to scan a new file, i got the error "Device is not open".
My code is as below. I found that the issue is generated only in case when the "ExportToDisk" line is executed. after executing this function I am not able to scan a new file. it gives error of "Device is not open".
Dim objReport As CrystalDecisions.CrystalReports.Engine.ReportClass
objReport = New ReportName
objReport.SetDataSource(DataSource)
objReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "FileName")
And after the calling this method scanner not recognized any devices. So i dont know why this happened. TSScan is working fine until we call crystal report export to disk method.
try this code:
objReport.ExportOptions.DestinationType = CRExportDestinationType.crEDTDiskFile;
objReport.ExportOptions.FormatType = CRExportFormatType.crEFTCrystalReport;
DiskFileDestinationOptions fileOption = new DiskFileDestinationOptions();
fileOption.DiskFileName = "Test.rpt";
objReport.ExportOptions.DiskFileName = fileOption.DiskFileName;
objReport.Export(false);
I'm using the JasperReports Java API. I'm using JRDesignExpression to show values on a report, with code like this:
JRDesignExpression expression = new JRDesignExpression();
expression.setText("$F{" + fieldName + "}");
I saw that $F{somename} syntax in some online examples and just copied it, because setText() is not documented, like much of the JasperReports API:
http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/design/JRDesignExpression.html#setText(java.lang.String)
But is there some documentation somewhere else that describes that syntax? I'd like to specify formatting for numbers, for instance.
The syntax is correct. I had the same issue, I applied the text and saw null value instead. It turned out that the problem was with my code. I compiled the JasperDesign to JasperReport before I did all the changes. So make sure you do all modifications, and then compile.
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
//perform all modifications
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
//continue with export
And also make sure you actually add it to some JRDesignTextField
I am working in asp .net mvc3.
I have these statements in controller class:
PdfWriter.GetInstance(doc, new FileStream((Request.PhysicalApplicationPath + "\\Receipt5.pdf"),
FileMode.Create));
doc.Open();
PdfPTable table = new PdfPTable(2);
table.AddCell("tt[0]");
table.AddCell("tt[1]");
doc.close();
All time my values are changing but in pdf sometimes showing old result. please tell me what should i do for it that whenever i press done button then new pdf document should generate.
i am using iTextSharp to generate pdf.
It seems that you're not able to replace the old file cause it is locked.
Try to delete it and see what happens.
Anyway, consider that if more than one user tries to print the same document you can have a concurrency problem.
I would suggest you to use a generated file name:
var newFile = System.IO.Path.Combine(Request.PhysicalApplicationPath, Guid.NewGuid().ToString() + ".pdf");