Mange
-
Posts
15 -
Joined
-
Last visited
Content Type
Profiles
Forum
Events
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Security Advisories
Downloads
Posts posted by Mange
-
-
Hi all,
This is my environment:
- Windows 7
- IDE = NetBeans 8.0.2
- Create the reports with Jaspersoft Studio 5.5.1
- All fields and parameters are setup with font = SansSerif
Different languages are supported with property files.
For Chinese I use "Text_zh_CN.properties". I also have translation for Spanish and Portuguese
Chinese translation use Unicode. Example: “Equipment=u8bbeu5907”
This display properly exporting to docx-file but not to pdf.
I can’t find a way to get SansSerif to be included in the PDF Font Name. I tried the following alternatives:
- With a tip from another question I tried and downloaded “Arial Unicode.jar” and added to the “Java Build Path”. But I can’t find the Arial as an option for the PDF Exporter or as an option for PDF Font Name for the TextField.
- Changed the setting for a field (I test with one field to see if I can get it to work) and set it up as:
- PDF Embedded=true
- PDF Encoding= (Tested all that show Chinese)
- PDF Font Name=MHei-Medium
I get the following error when I run the report as a PDF:
Error - JasperViewer ListOfEquipment e:Could not load the following font :pdfFontName : MHei-MediumpdfEncoding : UniGB-UCS2-HisPdfEmbedded : true
I can’t figure out what is missing and where to get this to work.
-
I solved it like this:
Code:
try {
if (letterRB.isSelected()) {
f = new File("./reports/EquipToReview_L.jasper"«»);
} else {
f = new File("./reports/EquipToReview_A4.jasper"«»);
}
} catch (Exception fe) {
fe.printStackTrace();
}
String s = f.getAbsolutePath();
try {
jasperReport = (JasperReport) JRLoader.loadObject(s);
...It might not be the best solution but it works for me.
-
Note: If I use an "absolute path" I don't get the error. But I don't have that since the user can select to install anywhere.
-
Hi,
I have an app where what to print is selected (i.e. list of equipments) and when done the user click print that launch the JasperViewer.
Code:
JasperReport jasperReport;
try {
if (sizeLetterRB.isSelected()) {
jasperReport = (JasperReport) JRLoader.loadObject(
"./reports/ListOfEquipment_L.jasper"«»);
} else {
jasperReport = (JasperReport) JRLoader.loadObject(
"./reports/ListOfEquipment_A4.jasper"«»);
}
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
param, new JRTableModelDataSource(table.getModel()));
JasperViewer.viewReport(jasperPrint,false);
} catch (Exception e) {
e.printStackTrace();
}This works fine the first time the report is viewed and printed. After exit and the print button is clicked again in the selection screen I get the following stack trace:
--- stack trace ---
java.io.FileNotFoundException: .reportsListOfEquipment_L.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:75)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:64)
at print.ReportListOfEquipment.jasperPreview(ReportListOfEquipment.java:369)
at print.ReportListOfEquipment.printButton_actionPerformed(ReportListOfEquipment.java:451)
--- end stack trace ---
Have I missed a close or something after the Viewer is launched?
TIA,
Magnus
-
Thanks C-Box!
I can't figure out how/where to put it all together ...
I create a Def style - default but no conditions
I create RedBold with Def as parent - conditions "new Boolean($F{numOfTD}.equals("0"))" (it is a string)
I have tried to set none or both styles on the field and check/un-check the "Styled text" flag but always use Def or RedBold?
What to put where in iRepoprt1.2.6?
-
Similar problem but formating ...
I have $F{count} and if = 0 I want bold and red, otherwise just keep it default.
-
OK, I changed the parameter to a string and I send in the filename instead of the image and now it show just fine :)
Thanks again for the pointer!
-
Thanks!
You are so right. I read the file into an ImageBuffer using the ImageIO.read().
I will do a litle better test with a variety of files and I can post my findings.
-
Hi,
In my selection screen of data for the report I let the user pick a logo to be included in the report. I picked a png-file (and showed it as an Icon on a label) that has a transparent background. The background came out black on the report. As a test I changed the image-element to use a direct path to the same file, instead of a parameter, and the background was transparent.
Anyone had the same experience?
A test with a gif-file showed up transparent when I sent it in as a parameter.
I also tried to set Transparent on/off but no difference.
-
Thanks!
The false flag helped a lot with the exit problem :)
With the modal problem I don't understand.
I usually open a JDialog in modal that then can open a JDialog in modal and it never caused any problems. The user jsut exit out in order as they were opened. The viewReport window is pop-up in foreground but is locked until I close the first window.
What is special about the window that viewReport open?
Thanks again!
PS. The reason I use modal is to prevent the user to open multiple of the same windows. It is not a problem with a report since there are no changes in the DB but I would like to use the same "flow" for all pop-up windows.
-
Hi,
I have an app with a couple of JDialog that is open from a menu. In one of them (Reports) I have this JDialog where the user can select what to print and then hit a button to print/pre-view.
Here is my first problem:
I open this JDialog with modal=true and I couldn't do anything on the screen untill I Alt-TAB to the (now covered with viewReport) selection screen and closed it. I would like to keep modal = true ...
Second problem:
To test I set modal=false and now I can use the viewReport as intended but when I close the pre-view, my App exit as well?
This is the line that open the viewReport:
Code:
JasperReport jasperReport = (JasperReport) JRLoader.loadObject("./reports/ListOfEquipments.jasper"«»);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,param, new JRTableModelDataSource(table.getModel()));
JasperViewer.viewReport(jasperPrint); -
I found the problem and as usual it was a simple error. After going back and forth between Fields and Parameters I found that I have declared the Field as a string...
:blush:
-
I have a problem getting an image per row in detail.
I have created my own tableModelwhere I define the columns as String, Object
I then use setValueAT to insert 2 buffered images.
I get a ClassCastException when I try to fill the report.
jasperPrint = JasperFillManager.fillReport(jasperReport, param, new JRTableModelDataSource(table.getModel()));
TIA
PS. If I change the report to java.awt.Image the report doesn't compile.
PPS. I tried to just insert a direct path in my table instead of BI and it worked. Howerver, I will create charts as BI per row in my table.
--- java ---
Code:
static class MyTableModel extends AbstractTableModel {
private String[] columnNames = {"Field",
"image2"};
private Object[][] data = {
{"First Line", new Object()},
{"Second Line", new Object()}
};
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
fireTableCellUpdated(row, col);
}
}--- jrxml ---
Code: [code]
<parameter name="image1" isForPrompting="true" class="java.lang.Object"/>
<image scaleImage="RetainShape"
evaluationTime="Now"
hyperlinkType="None"
hyperlinkTarget="Self" >
<reportElement x="4" y="33" width="376" height="162" key="image-1"/>
<box topBorder="None" topBorderColor="#000000"
leftBorder="None" leftBorderColor="#000000"
rightBorder="None" rightBorderColor="#000000"
bottomBorder="None" bottomBorderColor="#000000"/>
<graphicElement stretchType="NoStretch" pen="4Point" fill="Solid" />
<imageExpression class="java.lang.String"><![CDATA[$F{image2}]]></imageExpression>
</image>--- error ---
Code: [code]
java.lang.ClassCastException
at Simple_Report_1158667614968_767996.evaluate(Simple_Report_1158667614968_767996.java:167)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:807)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:447)class java.awt.image.BufferedImage
at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:430)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at jaspertest1.JasperReportsIntro.main(JasperReportsIntro.java:46)
NESTED BY :
java.lang.ClassCastException
at Simple_Report_1158667614968_767996.evaluate(Simple_Report_1158667614968_767996.java:167)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:807)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:447)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:430)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at jaspertest1.JasperReportsIntro.main(JasperReportsIntro.java:46)
NESTED BY :
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{image2}
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:183)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:539)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:507)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:807)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:447)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:430)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:277)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1289)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at jaspertest1.JasperReportsIntro.main(JasperReportsIntro.java:46)
Caused by: java.lang.ClassCastException
at Simple_Report_1158667614968_767996.evaluate(Simple_Report_1158667614968_767996.java:167)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:172)
... 16 morePost edited by: mbjorkman, at: 2006/09/19 12:50
-
Hi,
I'm very new (started 2 days ago) with JasperReports. Great product!
I did one tutorial (very simple) and added the following:
JasperViewer.viewReport(jasperPrint);
When tried to save in XLS format I got an error:
java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFCellStyle
I tried to open the jakarta-site so I can get the jar-file, but no luck. I will try later again.
I do wonder though, is it possible to remove some "Files of Type", like XLS, in the "Save As" ?
TIA
I can't get the pdf-export to include chinese characters.
in Products
Posted
Thanks Marianol.
I followed the links and since I added "Arial Unicode.jar" to the project I can select that font for my text field.
I added the jar-file to the libraries in my project and "C:Program FilesNetBeans 8.0.1javamoduleslocale".
Word is working but the PDF exporter show the following Error - JasperViewer ListOfEquipment e:com.lowagie.text.DocumentException: Font '' with 'Cp1252' is not recognized.
What to do so I can select Arial Unicode for the PDF Font Name?