Jasper Reports does not bold text in a pdf file - jasper-reports

Using jasper reports (1.3) together with itext library (1.3.1) to make pdf reports. Font is defined as follows:
<reportFont name="font-normal" isDefault="true" fontName="Code2000" size="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="CODE2000.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
We explicitly set isBold="true", however nothing in the report is bold. The font CODE2000.TTF can be used in MS Word with bold style. We also tried without success setting isBold="true" on the element inside like in:
<textField>
<reportElement positionType="Float" x="0" y="120" width="694" height="14"/>
<textElement>
<font size="9" pdfFontName="CODE2000.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String">
"TITLE:"+str($P{title})
</textFieldExpression>
</textField>
Any help is appreciated.

Related

How to combine two textFields into one box in RTF generated by Jasper reports?

I use Jasper Reports to generate RTF file.
In RTF each textField is represented as separate box:
I tried to use one frame for textFields:
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="220" y="45" width="406" height="75"/>
<textField>
<reportElement positionType="Float" x="0" y="0" width="406" height="60"/>
<textElement>
<font fontName="Arial" size="8"/>
</textElement>
<textFieldExpression><![CDATA["Address:"]]></textFieldExpression>
</textField>
<textField hyperlinkType="Reference" hyperlinkTarget="Blank">
<reportElement x="0" y="57" width="200" height="15" key="textWithStyle" style="LinkField"/>
<textElement>
<font fontName="Arial" size="8" isUnderline="true"/>
</textElement>
<textFieldExpression><![CDATA["here"]]></textFieldExpression>
<hyperlinkReferenceExpression><![CDATA["http:adress"]]></hyperlinkReferenceExpression>
</textField>
</frame>
But textFields also in the different boxes.
Is it possible to combine several textFields into one box like the following?
I know that I can add each text to one textField, but sometimes I need two separate textFields that I can manage inside one box.

jasper reports grouping not working as expected

I am running a jasper report on an select query, I am grouping the result by few values and using the same fields in my header
Below is my jasper group expression and header.
<groupExpression><![CDATA[$F{tray_code} + $F{card_id} + $F{card_position}+$F{card_number}+ $F{card_from_date}+ $F{card_to_date} + $F{week_number}+$F{patient_id} + $F{patient_full_name}]]></groupExpression>
<groupHeader>
<band height="15">
<textField isBlankWhenNull="true">
<reportElement x="5" y="0" width="20" height="14" uuid="97fd5e2c-50e4-46e4-9c1b-0453f5cd05b5"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{tray_code}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="26" y="0" width="44" height="14" uuid="d16ea2fb-367a-4b5e-986e-bc19669c3091"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{card_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="95" y="0" width="25" height="14" uuid="b7eb1f75-44d4-467e-8463-29f6f6f4555b"/>
<textElement textAlignment="Center">
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{card_position}]]></textFieldExpression>
</textField>
<textField pattern="">
<reportElement x="120" y="0" width="55" height="14" uuid="10e4bc1b-cfbb-478d-bd10-a6284bd3bac1"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy").format(new SimpleDateFormat("yyyy-MM-dd").parse($F{card_from_date}))]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy">
<reportElement x="175" y="0" width="55" height="14" uuid="a7d34de5-c4de-4093-9da7-96119450c3ab"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy").format(new SimpleDateFormat("yyyy-MM-dd").parse($F{card_to_date}))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="230" y="0" width="24" height="14" uuid="9cf3bce2-cb70-45e7-8199-0d6c8003ce53"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{week_number}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="270" y="0" width="67" height="14" uuid="d9e50bb7-1616-4d84-b92f-246abd05ae7b"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{patient_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="337" y="0" width="250" height="14" uuid="b06f0d0d-739b-4e2a-a2bc-1686c9d5cbfe"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{patient_full_name}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="14" width="752" height="1" uuid="968c2e25-462d-4b0a-90e2-34570db25d0f"/>
<graphicElement>
<pen lineWidth="1.0" lineStyle="Dashed" lineColor="#999999"/>
</graphicElement>
</line>
<textField>
<reportElement x="70" y="0" width="25" height="14" uuid="7f4ba299-706f-4ba6-aafc-ffa47b0e4374"/>
<textElement textAlignment="Center">
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{card_number}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
According to the above group expression, I expect only one header for a group, But I see the group header for the same group is repeated in my output file ! Please let me know what I am doing wrong.
Thanks in Advance.
So there is an issue that happens when you use multiple group headers. The first header behaves like expected ordered by Column Value A only on unique values.
The 2nd header using Column Value B will print on every row despite being non-unique values.
In theory you should be able to use:
1.
ORDER BY ValueA, ValueB
to properly display the report assuming you are using sql, plsql, etc...
However, in my case that did not happen, though for others it seems to work.
2.
Use subreports to attach the minor differences via unique reports.
You create a root report with empty details.
Then you create Unique reports to serve as sub reprots.
Finally, you use the subreport element to link the values into the root report. Though that is a good bit of work and may cause repeat code.
A hacky way I used was:
A mixture of "Print When Expressions" with logical boolean like below
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("QueryA") && $P{P_parameter} == null)
and
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("P_QueryA") && $P{P_parameter} != null)
with two group headers and a column header. The column header will not repeat for every row so you assign one of the booleans expressions to it's "print when" so it does not always print. The first group header will not repeat for every row and works. The 2nd group header is used for the times you DO want it to repeat for every unique value since it always prints for every row, and you use the other boolean on it's "print when".
Hope it helps

jasper excel report export green mark coming

I am using jasper stuido 6 to generated excel report.
After generating report I am getting green mark on cell wherever is number is coming as shown below image
same green mark is not coming from text value only.
I tried to set the below jasper property
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
and used below code
<jr:column width="50" uuid="d3d82c7c-1121-474f-b0f3-00e80cda4489">
<jr:detailCell height="20">
<textField>
<reportElement style="WhiteBackColor" x="0" y="0" width="50" height="20" uuid="1b71e76d-8111-43ee-9cfb-9070ffcf1f6d">
<printWhenExpression><![CDATA[$F{zeitQuartal}.matches("-?\\d+(\\.\\d+)?")]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="Calibri" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[Double.parseDouble($F{zeitQuartal})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
Then green mark disapper from the generated excel report
but if any text like come in between number that is disappearing

iReport 4.7 set character bold,but there is no effect on pdf

I use label to set Chinese and use bold to make the character bold,it has effect in ireport software,but there is no effect when I print it in pdf.
<staticText>
<reportElement uuid="20445ac6-99f7-44aa-9e7f-f9b658decf3b" x="0" y="0" width="554" height="23"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[学生预防性体检结果]]></text>
</staticText>
I select microsoft yahei fonts as my Chinese font , simsun font as my text field fonts ,put wryh.jar under the libs of project and the fonts can be seen bold when i printview it in pdf .My problem is solved.thanks everyone

Serial Number Repeating in Jasper Reports

I have used $V{REPORT_COUNT} TO DISPLAY SERIAL NUMBER OF THE RECORDS.For Each Record that is fetched from the database the serial number is displayed correctly.
However if one record that is printed has data more then it can accommodate on a page, it is displayed on the next page. I am fine with that too, however the serial number is again shown for that page Eg. 3 is the serial number and if 3 could not be accommodated on the same page the record is written in the next page and the order of serial number is 1 2 3 (First Page) 3 4 5 etc(second Page).
I want 3 to be displayed only once in the first page and not in the second page. I have uploaded a image of my layout and I do not want to show the circled part I am Using Ireport to design the page
Text Field Properties
This is for the REPORT_COUNT TEXTFIELD
<reportElement
mode="Opaque"
x="0"
y="0"
width="15"
height="30"
backcolor="#D3D3D3"
key="textField-9"
stretchType="RelativeToBandHeight"
positionType="Float"
isPrintRepeatedValues="false"
isRemoveLineWhenBlank="true"
isPrintWhenDetailOverflows="true"/>
<box topBorder="Thin" topBorderColor="#000000" leftBorder="Thin" leftBorderColor="#000000" rightBorder="Thin" rightBorderColor="#000000" bottomBorder="Thin" bottomBorderColor="#000000"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Times New Roman" pdfFontName="Times-Bold" size="10" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
This properties for the right hand side text box which displays data:
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Opaque"
x="12"
y="0"
width="523"
height="13"
forecolor="#000000"
backcolor="#D3D3D3"
key="textField-2"
positionType="Float"
isRemoveLineWhenBlank="true"/>
<box topBorder="Thin" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="Thin" rightBorderColor="#000000" bottomBorder="Thin" bottomBorderColor="#000000"/>
<textElement verticalAlignment="Middle">
<font fontName="SansSerif" pdfFontName="Times-Bold" size="8" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[" "+$F{vesselName}+($F{type} == null ? "" : " ("+$F{type}+")")]]></textFieldExpression>
</textField>
Can you just tell us the properties you have set for the text fields?
I have just made a rough design of your scenario and I did not come across your issue. The row_count value is not getting repeated.
Refer below image.
Set a few properties to your variable:
<variable name="RECORD_COUNT" class="java.lang.String" incrementType="Column" calculation="Count">
<initialValueExpression><![CDATA[1]]></initialValueExpression>
</variable>