venkatgvr Posted December 6, 2011 Share Posted December 6, 2011 Hi,I'm unable to find an option in ireport tool to add a check box to jrxml content.my requirement is to add check box in jrxml content and at run time when I generate the pdf report out of jrxml,I should be able to pass data which specifics whether the check box should be checked or not.i.e (for instance for name field I could able to add a field and text box at same time at run time I'm able to pass the name while generating the report similarly I'm expecting same for my check box funtionlity).please let us know the possible solution.Any help is highly appreciated. Thanks Link to comment Share on other sites More sharing options...
svenn Posted December 6, 2011 Share Posted December 6, 2011 One way is to layer a checked and unchecked box image on top of each other. Now use the print when expression to determine which image to display on the report. Link to comment Share on other sites More sharing options...
venkatgvr Posted December 7, 2011 Author Share Posted December 7, 2011 Hi,Thank you for your quick reply.Please can you post some sample java code to "determine which image to display on the report." at run time as post in below thread.Right now I'm using below sample code to pass data to text field at runtime, where name and address are text fields specified in jrxml.1) Java Code2) Jrxml contentAny help is highly appreciated.Thanks.Code:1)<========================Java Code ==============================>String path = "D:\\dynamic_data";HashMap map = new HashMap();map.put("name", "tcs");map.put("address", "hyd");jasperReport = JasperCompileManager.compileReport(path+".jrxml");jasperPrint = JasperFillManager.fillReport(jasperReport, map, JasperExportManager.exportReportToPdfFile(jasperPrint, path+new JREmptyDataSourc());2)<=================JRXML Content======================><?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name=".jrxml" pageWidth="595" pageHeight="842" columnWidth="495" leftMargin="57" rightMargin="43" topMargin="43" bottomMargin="43"> <queryString language="SQL"> <![CDATA[]]> </queryString> <field name="name" class="java.lang.String"/> <field name="address" class="java.lang.String"/> <variable name="name" class="java.lang.String"/> <title> <band height="45" splitType="Stretch"/> </title> <pageHeader> <band height="45" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="25" splitType="Stretch"/> </columnHeader> <detail> <band height="73" splitType="Stretch"> <staticText> <reportElement x="106" y="12" width="62" height="15"/> <textElement/> <text><![CDATA[Name]]></text> </staticText> <textField isBlankWhenNull="false"> <reportElement x="224" y="12" width="72" height="15"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression> </textField> <staticText> <reportElement x="106" y="42" width="62" height="13"/> <textElement/> <text><![CDATA[Address]]></text> </staticText> <textField isBlankWhenNull="false"> <reportElement x="224" y="41" width="72" height="15"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="45" splitType="Stretch"/> </pageFooter> <lastPageFooter> <band height="45" splitType="Stretch"/> </lastPageFooter> <summary> <band height="45" splitType="Stretch"/> </summary></jasperReport> Link to comment Share on other sites More sharing options...
lenalex Posted August 26, 2012 Share Posted August 26, 2012 Another way is to use unicode:... <field name="COLUMN_4" class ="java.lang.Boolean" />...<textFieldExpression class="java.lang.String"> <![CDATA[$F{COLUMN_4} ? "u2611" : "u2610"]]></textFieldExpression> ...Post Edited by lenalex at 08/26/2012 19:51 Link to comment Share on other sites More sharing options...
mathiaslin Posted November 24, 2013 Share Posted November 24, 2013 This does not print a character with unicode u2611 (checkbox), but the string "u2611" itself; at least not with JR 5.5.0. I am using JasperStudio. I also noted that when I enter the "class=java.lang.String" in the textFieldExpression, the JasperStudio report designer automatically removes that attribute. I am using the ☐/☑ characters directly, not unicode encoded, works fine as well. Link to comment Share on other sites More sharing options...
hacotjerome Posted April 22, 2015 Share Posted April 22, 2015 Need a character before the u to work Link to comment Share on other sites More sharing options...
manish.taneja01 Posted February 20, 2019 Share Posted February 20, 2019 Exporting the jasper report to pdf with unicode is not printing the checkboxes. Link to comment Share on other sites More sharing options...
kojots Posted April 6, 2020 Share Posted April 6, 2020 printing to pdf works, but you need to change the field font, eg. to DejaVu Sans Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now